Valheim-Modding / Jotunn

Jötunn, the Valheim Library.
https://valheim-modding.github.io/Jotunn/
MIT License
126 stars 40 forks source link

[BUG] Dropdown component not in UI layer #387

Closed SpikeHimself closed 1 year ago

SpikeHimself commented 1 year ago

Details: Jotunn Version: 2.10.4 Jotunn Submodule(if applicable): - Repeatability(Consistent(100%), Inconsistent(50%), Rare(1%), Unknown(==1)): 100%

Problem Description: The Dropdown component of the gameobject created by GUIManager.CreateDropDown has the incorrect layer set. It is 0, where 5 (UI Layer) is expected.

Expected Behaviour: var dd = GUIManager.Instance.CreateDropDown( ... ) dd.GetComponent\<Dropdown>().gameObject.layer == 5

Actual Behaviour: var dd = GUIManager.Instance.CreateDropDown( ... ) dd.GetComponent\<Dropdown>().gameObject.layer == 0

Link to your server's and client's LogOutput.log It's not visible in any logs, but a user of my mod has posted a screenshot here: https://github.com/SpikeHimself/XPortal/issues/11

SpikeHimself commented 1 year ago

Additonal findings:

Same as above applies to the dropdown's "Template" child, i.e.

var dd = GUIManager.Instance.CreateDropDown( ... )
dd.transform.Find("Template").gameObject.layer == 0  // Should be 5

Changing both of these values to 5 (i.e. GUIManager.UILayer) solved the issue for my mod's user.

MSchmoecker commented 1 year ago

Thanks for the report. It's actually interesting that it behaves like this, since the dropdown is initally created with Unity's own utility class DefaultControls.CreateDropdown() that even seems to set the layer correctly for some children.

Agreed, it makes sense that the controls are always spawned under the correct UI layer. As far as I can tell you already fixed it in your mod but feel free to open a PR if you want to provide a fix in Jotunn, too. Otherwise I will put it on my to-do list and get to it when I get to it.