0
\$\begingroup\$

As can be seen in the following video:

https://youtu.be/zb3uMUqub00

The dropdown stays stuck open when Unity launches the game. This happens even with a non-modified dropdown that is plopped as a new UI object inside the canvas.

I tried a blank project, and the issue does not reproduce. I tried in a blank project, and the dropdown works. I tried researching a solution, but not too sure how to find one with this problem. Maybe someone here will have an idea or two.

The repo can be downloaded at https://github.com/DenisLabrecque/Warglobe if desired.

\$\endgroup\$
1
\$\begingroup\$

My UI System script, a parent of the dropdown, has a statement that gets all components, whether active or not, in children:

m_Components = GetComponentsInChildren<Component>(true).ToList();

It then goes through those components and turns them on (in case an artist turned them off or something like that):

     foreach (Component screen in m_Components)
     {
        screen.gameObject.SetActive(true);
     }

The assumption here is that each component will be a screen. However, it enables the dropdown template as a side effect, which makes the dropdown's initial state be open.

Instead, the loop should have been written as follows:

     foreach (Component screen in m_Components)
     {
        if (screen is UIScreen)
        {
           screen.gameObject.SetActive(true);
        }
     }
\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.