Author Topic: Setting Alpha makes panel flicker  (Read 4849 times)

AGB

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 74
    • View Profile
    • Steam Defense
Setting Alpha makes panel flicker
« 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();
I'm a busy man... I have places to go,monsters to kill...

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Setting Alpha makes panel flicker
« Reply #1 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.

AGB

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 74
    • View Profile
    • Steam Defense
Re: Setting Alpha makes panel flicker
« Reply #2 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?
I'm a busy man... I have places to go,monsters to kill...

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Setting Alpha makes panel flicker
« Reply #3 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.