Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: AGB on December 28, 2013, 07:44:12 AM

Title: Setting Alpha makes panel flicker
Post by: AGB on December 28, 2013, 07:44:12 AM
When adding a child using NguiTools.Addchild, that has panel, and setting alpha to 0, it makes panel flicker, because alpha set is not working right away, only after late-update. The only way is to refresh panel?


UIPanel panel = NGUITools.AddChild(ParentPanel, PanelPrefab.gameobject).GetComponent<UIPanel>();
//Setting panel alpha to 0, for slow fading in future. (PanelPrefab had alpha=1)
panel.alpha = 0;
//this is what i have to do, to avoid flickering :(
panel.Refresh();
Title: Re: Setting Alpha makes panel flicker
Post by: ArenMook on December 28, 2013, 04:39:44 PM
Yes, that's correct. It's not setting the alpha that makes them flicker. You bring them in with a full alpha, then you change the alpha, but the change won't take effect immediately. You can fix this easily by setting the alpha to 0 on the prefab itself.
Title: Re: Setting Alpha makes panel flicker
Post by: AGB on December 29, 2013, 02:43:52 AM
Yes, setting alpha to 0 in prefab helps, but is not really convenient. Will it help, if i change alpha to 0 on PanelPrefab, before AddChild?
Title: Re: Setting Alpha makes panel flicker
Post by: ArenMook on December 29, 2013, 06:16:05 PM
Why is it not convenient? It would be the proper thing to do in this case. If you can't, then you either need to call Refresh() as you were doing before, or change it before instantiation, yes.