- Home /
Dropdown menus for settings have randomly stopped working
My settings panels have stopped working all of a sudden (they did work in the main menu, and during gameplay). When you open a dropdown menu (e.g. to set resolution), a new game object called a 'blocker' is instantiated and none of the options are intractable - they are either not there, or are greyed out. The 'blocker' could be a part of the dropdown system because the V-sync option still works (the only dropdown that does) - it appears when the menu is open, then vanishes when the menu is closed.
I'm a C# noob, so any advice would be much appreciated! I've hashed together bits of code from different sources. I can't think of what has changed to cause this issue :/
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
using System.IO;
public class SettingsController : MonoBehaviour {
public static int[] AliasingOptions = new int[4] { 0, 2, 4, 8 };
public static int[] ScreenResolutions = new int[4] { 0, 2, 4, 8 };
public Dropdown ResolutionDropdown;
Resolution[] resolutions;
public Slider volSlide;
public void SetQualitySettings(int value)
{
QualitySettings.SetQualityLevel(value);
}
public void SetVSyncSettings(int value)
{
QualitySettings.vSyncCount = value;
}
public void SetAntiAliasing(int value)
{
QualitySettings.antiAliasing = AliasingOptions[value];
}
public void ToggleFullScreen(bool value)
{
if (Screen.fullScreen == true)
Screen.fullScreen = false;
else
Screen.fullScreen = true;
}
void Start()
{
resolutions = Screen.resolutions;
for (int i = 0; i < resolutions.Length; i++)
{
ResolutionDropdown.options.Add(new Dropdown.OptionData(ResToString(resolutions[i])));
ResolutionDropdown.value = i;
ResolutionDropdown.onValueChanged.AddListener(delegate { Screen.SetResolution(resolutions[ResolutionDropdown.value].width, resolutions[ResolutionDropdown.value].height, true); });
}
}
void Update()
{
ChangeAudioVolume();
}
string ResToString(Resolution res)
{
return res.width + " x " + res.height;
}
void ChangeAudioVolume()
{
AudioListener.volume = volSlide.value;
}
}
Answer by Mikael-H · Apr 12, 2017 at 07:04 PM
There's a bug that was introduced in Unity 5.6 that may or may not be your issue. If I understand correctly it appears if you deactivate and then deactivate a parent canvas. It has been discussed in this thread.
I downgraded our project to 5.5.3 and that worked. For me it was actually possible to just open the whole project in 5.5.3 and just edit the text file with the version number in it but your mileage may vary. As you state that you are a beginner, let me press the importance to backup projects before doing stuff like that! (By backup I of course actually mean keep your project under version control... )
Otherwise you may try an wait for the next patch as it seems they have fixed it and it will probably be rolled out ASAP.
Ah that's interesting, but it's odd that the V-sync option works but the others don't. I looked into the screenspace thing and that doesn't seem to be the issue here; you can see in the image that the options are all there, they're just not visible. I double clicked the options in the inspector and it just took me to the dropdown menu :/
Thanks for the advice, looks like reverting or waiting for the patch!