Dropdown's order in layer

I have a worldspace canvas with “order in layer = -100”. Then I put a dropdown into a panel inside this canvas. When i stare at panel / dropbox with oculus, pointer (orange dot) is displayed correctly,

but when i expand the dropbox, i found that expanded parts order in layer is 30000 and pointer falls behind. (Hovering on Option C)


Why? I assume to draw this part on top of everyting but is this logical? Should i change each dropdowns order value (when clicked) in runtime allways??

If you look at the child of the dropdown called “Template” you will see that it also has a canvas component which is set to override canvas components higher in the hierarchy and set the order to 30000 again. Not sure if you need to just uncheck the override, or update the value, but it is there that you need to look. The “template” is disabled and it’s essentially the “prefab” the script on the dropdown uses to create the list.

Thanks for reply.
I’m using Unity 5.3.4p1 and dropdown’s template prefab does not contain a canvas component. I’ve put one myself and changed it’s order in layer to -100 and override the sorting. However, when i run and expanded the dropdown, it chages order value to 30000 again.

ah, ok, it appears that that component is added when you click/interact with the dropdown the first time.

https://bitbucket.org/Unity-Technologies/ui/src/0155c39e05ca5d7dcc97d9974256ef83bc122586/UnityEngine.UI/UI/Core/Dropdown.cs?at=5.2&fileviewer=file-view-default

// line 272
Canvas popupCanvas = GetOrAddComponent<Canvas>(templateGo);
popupCanvas.overrideSorting = true;
popupCanvas.sortingOrder = 30000;

it’s hardcoded into the script :frowning:

you might be able to do something with a function linked with an OnPointerClick event? you’d need it to go after the dropdown’s script though, once the canvas has been added

2 Likes

Thanks a lot! :slight_smile:

1 Like

I know this is an old thread, but I fix this adding this in a new script that I added to the “Template” object of the dropdown

 private void OnEnable()
    {
        Canvas canvas = GetComponent<Canvas>();
        if(canvas)
        {
            print("canvas finded");
            canvas.sortingOrder = -1;

        }
    }
3 Likes