Nested canvas bug

Weird bug related to UI.Canvas was accidentally found by me while I was developing new menu for our upcoming game SummerCatchers. Btw, follow us ;)
As far as you may know Canvas can have other Canvases as children objects. This is very useful in optimization purpose because sub-canvas isolates its UI elements from other canvases (parent and siblings) thus modifying one of its children won’t cause rebuilding of batched mesh for other canvases.
The bug is as follows.

If Canvas has a nested Canvas disabling and subsequent enabling of an outer Canvas causes an inner one to weirdly modify and “lock” its RectTransform. By “locking” I mean that RectTransform becomes uneditable via Inspector since now its values are driven by Canvas.
This bug is already reported to Unity QA team and marked as reproducable and sent to developers for resolution.
As far as I understand there is no way to workaround this bug. However, and this may sound funny, this bug motivates not to disable/enable UI GameObjects because that’s not cool and Unity does not like it at all.

How to reproduce

What causes this bug is wrapped in obscurity because Canvas is part of core codebase not an open source part of UI. But I guess when we disable an outer Canvas an inner one realizes its not a sub-canvas anymore so it must take care of its RectTransform. But it doesn’t want to admit its a sub-canvas again after outer Canvas is enabled again. What a tense relationship!

Share Comments
comments powered by Disqus