I'm having a bit of trouble with an exotic case: for a certain screen transition type, I parent an object with a panel hosting some widgets to another object with a texture clipped panel, play some animations with higher-level texture clipped panel, then restore the hierarchy back. Trouble is, I can not figure how to disable the moved panel for the duration of that scene without killing the rendering of all child widgets.
To explain, here is the standard hierarchy:
Clipped panel (enabled)
Normal panel (enabled)
- Widget
And here is what happens for the duration of screen transition:
Clipped panel (enabled)
- Normal panel (disabled)
- - Widget
Problem is, the moment I disable the normal panel, every single widget stops rendering, probably because it's supposed to do that due to UIPanel OnDisable method. But I don't want that: I want the widgets to continue being rendered, just using the higher panel in the hierarchy: clipped one. And I'm unable to do that. So far I have tried lots of combinations and different orders of normal UIPanel component .enable setting, widget.ParentHasChanged() calls, direct widget.panel parameter reassignment, panel Refresh() calls, and some other methods, but nothing seems to work - absolutely invariably, once I disable the normal panel, every single widget linked to it will disappear.
The only way to get the desired behavior I have found was to destroy the UIPanel manually from the inspector. That's obviously very undesirable way of doing things, I'd prefer not to have a hassle of caching all panel properties to recreate it later and I'd prefer not to risk GC rushing in during 1 second long buttery smooth animation. I just need to replicate what happens to child widgets when a panel is removed, without actually removing (only disabling) it. But I'm not seeing any OnDestroy behavior in UIPanel, so I'm not sure how exactly widgets actually move under command of a higher panel. It's reliably happening and it's exactly what I need, but I'm unable to track how it's done. Can someone shine a light on that?