[Solved] Public variables slots not loading

Hi everyone:

Juan’s here again to ask you a question. I’m very excited with Glitch Garden, on lesson 140 Ben showed how to customize sliders. I’m good with that but when coding the options controller somehow the slots involved in the public variable don’t pop out.

Things I tried:

I’ve checked the code several times and it matches with Ben’s. Perhaps there’s still something I’ve not scoped yet.
The code is attached to a GameObject named OptionsController
Did some reasearch on the Internet and find similar questions that unfortunately don’t match with this case.

Further description:

Sometimes a “The script cannot be loaded, Please check for compiler errors” appears right beneath the script slot. Again, I’ve compared the script more than twice and can’t see the error.

Could you give me a hand with things folks please?

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class OptionsContoller : MonoBehaviour {

public Slider volumeSlider, difficultySlider; 
public LevelManager levelManager; 
private MusicManager musicManager; 

// Use this for initialization
void Start () {
	musicManager = GameObject.FindObjectOfType<MusicManager>(); 
	volumeSlider.value = PlayerPrefsManager.GetMasterVolume (); 
	difficultySlider.value = PlayerPrefsManager.GetDifficulty (); 

// Update is called once per frame
void Update () {
	musicManager.ChangeVolume (volumeSlider.value); 

public void SaveAndExit (){
	PlayerPrefsManager.SetMasterVolume (volumeSlider.value); 
	PlayerPrefsManager.SetDifficulty (difficultySlider.value); 
	levelManager.LoadLevel ("StartMenu"); 

public void SetDefaults () {
	volumeSlider.value = 0.8f;
	difficultySlider.value = 2f; 	


Hello, does the name inside the script is the same as the file name?

Seems that you are missing an "r in the controller:

Hi Juanjauregui,
I don’t see any errors for the code that you provided. Have you closed and reopened Unity? Check your gameObject reference are they matching? It could be Unity’s designer is out of sync with the script. Is that the only error that you are receiving from the console?

1 Like

Hi Joao

Thanks for your reply! I’ve just double-checked the name of the script and the class. They do match up, anyway thanks for your suggestion!

Hi Greg

Thanks for your answer! I kind of understand the gameObject reference you mentioned but not in an complete way! Could you expand that a bit more. What I’ve done is to check names and they match, also I’ve changed the gameObject name slightly by adding a space (“Options Controller”) and still not working.

1 Like

Hi everyone!

So sorry to say that I just had a typo mistake as Joao_Dalvi mentioned. I couldn’t see the mistake when Joao corrected the script. No I understand what went worng. Thanks for your help guys.




Hi Juan,
I would avoid using spaces you should follow the pascal case naming convention for classes and methods. Camel case for your variables. These are the standard naming conventions. There is no rule that you have use them but it is helpful for other developers who might view your code.
.Net Naming Conventions link: here

I am glad you found the error.

1 Like

Hi Greg,

Thanks for you advice and sorry for not being in touch sooner! Yes your right I need to keep stick to the convention in order to avoid mistakes. Everything is new for me, my background is music, however I’m glad to find members like you in a supportive community.



Privacy & Terms