Author Topic: HUDText Labels Not Disappearing When Not In View  (Read 4434 times)

SketchWork

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 44
    • View Profile
HUDText Labels Not Disappearing When Not In View
« on: April 23, 2013, 09:03:38 AM »
Hi there,

I have a problem using the HUDText component.  I have a 2D camera for my NGUI interface and a 3D perspective camera for the game itself.  There are a few labels that have the UIFollowTarget on them with the UI camera set to the 2D NGUI camera and the Game Camrea set to my 3D perspective camera.  The target points to a empty object in the scene and I have ticked disable if invisible. 

Everything works perfectly while the labels are in view, but when the object leaves the side of the screen the labels stick to the side of the screen where the object left.

I am using Unity 4.1.

Thanks,

Justin
« Last Edit: April 23, 2013, 09:45:31 AM by SketchWork »

SketchWork

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 44
    • View Profile
Re: HUDText Labels Not Disappearing When Not In View
« Reply #1 on: April 27, 2013, 05:09:21 PM »
Any ideas?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: HUDText Labels Not Disappearing When Not In View
« Reply #2 on: April 27, 2013, 06:12:08 PM »
As I recall the disabling only happens if you structure your scripts like so:

GameObject (UIFollowTarget)
- Label
- Anything else you need to hide

This is done like so because the follow target should re-enable the label when it's in view, but it won't happen if the game object that UIFollowTarget script is on gets disabled. For this reason, only children of UIFollowTarget get disabled.

SketchWork

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 44
    • View Profile
Re: HUDText Labels Not Disappearing When Not In View
« Reply #3 on: April 28, 2013, 08:21:35 AM »
Excellent.  Thanks that was it.  I should have just looked in the source :)