Problems with Settings Menu

Updated on January 3, 2018 in [A] Brackeys Courses
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
5 on January 3, 2018

So i was watching brackey’s settings menu to help with an assignment that’s due next Monday. But I got stuck on two things. 1; The audio mixer doesn’t change the volume of my game and I don’t know how to link the two, and 2; The resolution dropdown doesn’t show any resolutions.

 

I copied the resolution code word for word, I included the UnityEngine.UI and dragged the dropdown onto the scriptholder in the inspector. I don’t know if anything is wrong here but my script is below and looks perfectly fine to me.

 

    public Dropdown resolutionDropdown;
    Resolution[] resolutions;
    void Start ()
    {
        resolutions = Screen.resolutions;
        resolutionDropdown.ClearOptions();
        List options = new List();
        for(int i = 0; i < resolutions.Length; i++)
        {
            string option = resolutions[i].width + " x " + resolutions[i].height;
            options.Add(option);
        }
        resolutionDropdown.AddOptions(options);
    }

 

Any help would be appreciated as my assignment literally relies on it. Thanks!

 

Edit: I resolved the audio problem

  • Liked by
Reply
1 on January 3, 2018

Try adding debug messages in your code. One before the for loop, one in the for loop and one after the for loop. The first one is to check if you code starts running (can be that your object is disabled or that you didn’t attach the script to the object, the one in the for loop will show the ‘options’ string that should be added to the options list, and the last one after the for loop will show the ‘options’ list. Check if there is a weird behavior in any part of your code, maybe unity can’t find any resolutions so the for loop will not run or runs only once.

on January 3, 2018

Try adding debug messages in your code. One before the for loop, one in the for loop and one after the for loop. The first one is to check if you code starts running (can be that your object is disabled or that you didn’t attach the script to the object, the one in the for loop will show the ‘options’ string that should be added to the options list, and the last one after the for loop will show the ‘options’ list. Check if there is a weird behavior in any part of your code, maybe unity can’t find any resolutions so the for loop will not run or runs only once.

From bennie3211

Thanks for the help!

 It turns out that whilst in the editor, the for loop gets ignored, but whilst built it decided to run the for loop, but the drop down now shows two of each resolution when built and none whilst in editor.

Show more replies
  • Liked by
Reply
Cancel
0 on January 3, 2018

I had the same issue with my settings menu. Although in the editor the drop down menu for the resolution wasn’t showing anything when i’ve built the game it was fine. But nothing happens when selecting one of them. (Same as the audio)

  • Liked by
Reply
Cancel
1 on January 3, 2018

May I know how did you solve the audio problem?

on January 3, 2018

May I know how did you solve the audio problem?

From LeeXx

 When pressing the audio source, it asks for an output, I simply dragged the audio master slider into the output and it worked.

Show more replies
  • Liked by
Reply
Cancel