Author Topic: best way to toggle HUD?  (Read 3169 times)

hankthewhale

  • Guest
best way to toggle HUD?
« on: November 29, 2012, 11:00:36 AM »
Right now I'm using SetActiveRecursively to toggle the HUD and placing the code wherever I need it to do so. What I would like is a single function that would do this that would be called anytime the HUD is needed to toggle on/off. Furthermore, I'd really like to hide the HUD instead of deactivating it which SetActiveRecursively appears to do. Any thoughts on where to start?


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: best way to toggle HUD?
« Reply #1 on: November 29, 2012, 02:03:43 PM »
Well, first of all use NGUITools.SetActive instead. It works in both 3.5.6 and 4.0.

I suggest transitioning via animations. In Windward I move windows off-screen via ActiveAnimation.Play() and set it to disable the object when the animation finishes. You can do the same thing with tweens.

hankthewhale

  • Guest
Re: best way to toggle HUD?
« Reply #2 on: November 29, 2012, 02:23:46 PM »
Ah great idea. Nice and simple too. Thanks.

Ewanuk

  • Guest
Re: best way to toggle HUD?
« Reply #3 on: November 29, 2012, 02:32:33 PM »
How would you suggest handling a display with varying content inside.

For example, a television screen displayed as a GUI with multiple channels. Each channel represented by a Game Object (with children and a UIPanel component).

Right now I'm using NGUITools.SetActive() to handle each child (turning to a channel sets it active, while making the previous channel inactive), but would it be better to just move the content on/off-screen as channels are flipped instead?

Thanks

mixd

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 22
    • View Profile
Re: best way to toggle HUD?
« Reply #4 on: November 29, 2012, 02:55:05 PM »
If you need to switch really fast between the channels, just tween them in/out of view. If not, probably best to deactivate so they aren't sitting in memory.

If they are all sharing the same sprite sheet, there is almost no cost to keeping them active assuming they aren't doing expensive operations every frame.