- Home /
What order do UI elements capture input?
My setup is, I have two Canvases which act as popup screens. They are set with Screen Space - Camera, and both are assigned to the same main camera. The front canvas has plane distance of 1 and the back canvas' plane distance is 9.
Each canvas has a fullscreen near-invisible "background-button" to call SetActive(false) and hide their canvas when you tap outside of the popup's content.
In my hierarchy these two canvases are siblings, with BackCanvas appearing above FrontCanvas. Everything renders as it should, front popup screen with its bg-button are overlaid on top of the back popup and its bg-button.
However when interacting with the popups, the back canvas is getting "input priority" over the front one. For example, when I tap outside the content of both popups, the back popup's bg-button is triggered and that screen closes, while the front canvas remains. A second tap will close the front one, since the back one was hidden.
None of this is using any scripts I've written, it's all just UI Buttons and their OnClick events hooked up to GameObject.SetActive calls.
I need to know what is causing this? Can I fix it? Thanks!
No one can point me in the right direction? The last time I asked about UUI events I only got one joking comment as a response. Is there really no information out there about event propagation / execution order? It seems like a core part of any UI framework so I'm baffled at how little help I'm getting here or from the docs.
Answer by callen · Feb 23, 2016 at 09:29 PM
I guess I figured it out, though after reading this thread who knows if it'll work going forward, since it was supposed to work correctly already using plane distance. However, the plane distance on my canvases are having no effect on the input capture order.
My solution was to set canvas' "Order In Layer" (I believe layerOrder in code) higher on the front-most canvas. Then it all seems to work as intended.