Hi,
so after updating to Unity 2019 (tested with 1.14f1 and 2.7f2) all our projects that were using Unity UI broke.
Basically the way we do our UI is every UI element is its own gameobject, when we show/hide an element we just enable/disable its Canvas, and set the sibling index to be on top of the previously shown UI so it renders properly. Also, every UI element has its own GraphicRaycaster attached.
In particular:
// comparing depth only makes sense if the two raycast results have the same root canvas (case 912396)
if (lhs.depth != rhs.depth && lhs.module.rootRaycaster == rhs.module.rootRaycaster)
return rhs.depth.CompareTo(lhs.depth);
The second half of the if expression was added new, it pretty much broke all our UI input/event detection. We basically show a âClick shieldâ behind our popups, the shield has a button/raycaster/canvas. We turn the click shield ON, then show the UI element on top. This in turn makes the ordering of s_Raycasters in RaycasterManager.cs be so that the raycaster for the shield is BEFORE the raycaster of the ui element, which is fine.
But the click shield and the UI element each have their own raycaster, so their ârootRaycasterâ are different, which means that depth comparison now doesnât fire, and it goes through to the index comparison which yields the incorrect result saying that the shield should be processed before the ui element on top, because of the order they got added to the s_Raycasters in BaseRaycaster OnEnable/OnDisable. Now when I hover over the popup which is on TOP of the click shield, the EventSystem preview/debug info says that Iâm still hovering over the clickshield which is wrong.
If I just go to the shield and turn on/off the raycaster, it removes/readds it self to the raycasters list at the END now, which means the index comparison now works.
The ordering of when things are turned on/off shouldnât matter, it should be driven by depth. I donât know what case that rooRaycaster was supposed to fix, the comment itself doesnât make any sense, itâs mentioning âroot canvasâ but comparing âroot raycasterâ. itâs definitely breaking other things and is clearly not tested enough and should not have been released.