Hello there, before posting this thread I’ve made a lot of researches these last days, and I’ve found some topics dealing the same issue but I found nothing really relevant for me. I’ve tried a lot of solutions but none of them worked on the long-term - or didn’t work at all.
I have a button called “Load Button”. When I click on it, it displays a panel which has a Dropdown as child. When I click on this Dropdown, it displays a list of maps that can be loaded by the rest of my script. When one of these maps is loaded, the panel is automatically hidden, and so is the dropdown. Clicking once again on the Load Button re-displays it.
However, when I try to load another map by clicking on the Dropdown, nothing appears. The Dropdown is stuck and doesn’t display any of its options (although they are all added to the list, I triple checked that).
When my dropdown is active :
And once I’ve load a map (in this example, “tamere”) :
No matter how many times I click on it, my dropdown remains like that. it IS interactable, it has all its options… I don’t know why. It seems that is a bug found by the Unity Issue Tracker that cannot be fixed, but I hope it is just a mistake from me (it will piss me off if I can’t fix that).
So, here is my code now :
public GameObject panelLoad;
[SerializeField] private Dropdown dropdownLoad;
public bool showGUI;
private string filePath;
void Awake()
{
panelLoad = GameObject.Find("Panel Load");
dropdownLoad = GameObject.Find("Dropdown Load").GetComponent<Dropdown>();
}
public void BUTTON_LOAD()
{
ADD_OPTIONS_TO_DROPDOWN();
DISPLAY_PANEL();
}
public void ADD_OPTIONS_TO_DROPDOWN()
{
UnityEngine.Object[] allTextFiles = Resources.LoadAll("Maps", typeof(TextAsset));
//print(fileInfo.Length);
List<string> dropOptions = new List<string>(allTextFiles.Length);
for (int i = 0; i < allTextFiles.Length; i++)
{
dropOptions.Add(allTextFiles[i].name);
//print(dropOptions[i]);
if (dropdownLoad.options.Count > 0)
{
dropdownLoad.ClearOptions();
}
dropdownLoad.AddOptions(dropOptions);
dropdownLoad.RefreshShownValue();
}
}
public void DISPLAY_PANEL()
{
showGUI = !showGUI;
Proceed_To_showGUI_Verification();
}
public void Proceed_To_showGUI_Verification()
{
panelLoad.SetActive(showGUI);
}
public void START_LOAD()
{
filePath = string.Concat("Assets/Resources/Maps/" + dropdownLoad.captionText.text + ".txt");
if (!File.Exists(filePath))
error.DISPLAY_ERROR_MESSAGE(14, "Error", "The file you are trying to load does not exist.");
else
{
//print(filePath);
LOAD_MAP_FROM_FILEPATH();
}
}
Don’t bother about LOAD_MAP_FROM_FILEPATH(), it has nothing to do with my problem. I’m sure the bug comes from panelLoad.SetActive(showGUI), since panelLoad is the parent of dropDownLoad, but I can’t figure out why, since the dropDown gameObject is disabled as soon as its parent itself is disabled. But the “why?” is a mystery for me.
Thanks for your answer.