Author Topic: The best way to hide/show UIWidget?  (Read 2672 times)

beyonddoor

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
The best way to hide/show UIWidget?
« on: May 03, 2016, 08:16:48 AM »
UIPanel.LateUpdate is invoked too often in my game, I found hide an UIWidget by GameObject.SetActive(false) will force the UIPanel to rebuild itself, So I have the following methods:
  • set alpha to zero
  • set localScale to zero
  • move to a invisible position out of camera
The method 2 and method 3 works as expected, both make UpdateGeometry called less often, but I want to know the best way to hide and show UIWidget (and widgets in its children), any advise is appreciated, thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: The best way to hide/show UIWidget?
« Reply #1 on: May 03, 2016, 02:10:58 PM »
Scale of 0 is invalid. You can't divide by zero.

If you want to avoid updates, SetActive(false) on the panel is the way to go. Don't bother with individual widgets. Enable/disable the panel they belong to instead.