So, the issue is actually not that the UIPanel keeps or loses the reference, it's that the Panel has another dedicated drawing class (UIDrawCall) which uses the custom geometry that UIpanel supplies and draw stuff on the screen with that. So making UIPanel "lose reference" just means that it doesn't provide the geometry from the given widget.Thanks for explaining. Still I see UIPanel as the one responsible for facilitating this process :)
Each time a new widget needs to be added, the entire geometry from that panel needs to be rebuilt, which takes time. There's no real way around this part, since moving widgets around has the same effect.I think you are wrong, because when moving a widget, there is a possibility of changing panels, widget position etc., thus the need to rebuilt geometry. But when I simply want to hide the widget and I know that it will not change it's panel/drawcall then the geometry would not have to be rebuilt.
Arguably, you can make a certain part of the geometry be drawn as normal but with alpha = 0, so it's not visible, but I'm not sure this is a healthy structure at all.I do not know how to solve it internally. Thanks for the pointer.
I think you are wrong, because when moving a widget, there is a possibility of changing panels, widget position etc., thus the need to rebuilt geometry. But when I simply want to hide the widget and I know that it will not change it's panel/drawcall then the geometry would not have to be rebuilt.It doesn't matter what happens -- whether you change the alpha, color, move the widget, or enable/disable it, either way it will cause the draw call(s) to be rebuilt. This is where the hit lies, and as Nicki pointed out there is no way around it -- custom flag or no custom flag.
It doesn't matter what happens -- whether you change the alpha, color, move the widget, or enable/disable it, either way it will cause the draw call(s) to be rebuilt. This is where the hit lies, and as Nicki pointed out there is no way around it -- custom flag or no custom flag.
Toggling alpha on panels brings in other bugsCan you elaborate on that, and is it something related to http://www.tasharen.com/forum/index.php?topic=9442.msg45270#msg45270 ?
Can you elaborate on that, and is it something related to http://www.tasharen.com/forum/index.php?topic=9442.msg45270#msg45270 ?
How so?
Widget
- Scroll View
-- Panel (constrained)
--- Sprite
Set widget alpha to 0, hit Play, move widget alpha to 1 -- it's visible. Use TweenAlpha instead -- same, it's visible.
Right off the bat, Awake is the wrong place for this. Awake should only set properties of the script you're executing it from. It should never be used to alter values of other scripts. Use Start for that.
No difference trying your hierarchy.
using UnityEngine; public class Test : MonoBehaviour { void Start () { GetComponent<UIWidget>().alpha = 0f; GetComponent<UIWidget>().alpha = 1f; } }
Unfortunately I can't reproduce this on my end from your descriptions, so I will need a repro case to have a look at.