Author Topic: NGUI AddUnitHUD and UnitHUD giving me issues  (Read 3422 times)

Stevorino

  • Guest
NGUI AddUnitHUD and UnitHUD giving me issues
« on: August 05, 2013, 04:27:04 PM »
So I've probably spent 6+ hours troubleshooting this.  This is where I am now:

HUDText works great when using UIFollowTarget.  Same goes for any other NGUI element I've used with UI Follow Target.

But I wanted to make it so that each object created it's unique NGUI object.... so I started to explore AddUnitHUD.

Whenever I attach AddUnitHUD to an existing game object - the first error I get is the 'No Camera Found for Layer (in my case, 'NGUI')'. 

Here's the weird part:

When I was troubleshooting, I used the UI Wizard in the NGUI drop down and created a new UI Root(2D) and camera.  I now see my NGUI 2 times over.  I transferred all of my panels & anchors over to the new UI Root Folder and deleted the old.  Everything works as it used to except I now no longer have the debug error.

Fixed - right?   No.  It happens again the next time the next time I attach AddUnitHUD to something else.  What could be going on?

------

While the above error was fixed, I noticed the script did execute properly in that it made a clone of the prefab.  But the widget would never activate - it was always disabled.  Even when my gameobject was in plain view, 10 meters above the ground (camera is at something like 150 above ground). 

Please offer some help, I'm already balding and this is expediting the process ;)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI AddUnitHUD and UnitHUD giving me issues
« Reply #1 on: August 05, 2013, 10:54:20 PM »
Check the layers. Most often these kind of issues are caused by not putting things on correct layers.

Stevorino

  • Guest
Re: NGUI AddUnitHUD and UnitHUD giving me issues
« Reply #2 on: August 05, 2013, 11:19:24 PM »
This is what I've got:

4 Cameras

1) Main Camera
Culling Mask = Every layer except 'Nothing', 'Everything', and 'NGUI'
UICamera Event Receiver Mask =  Nothing

2) Minimap Camera
Culling Mask = Default only
UICamera Event Receiver Mask = Default only

3) Minimap Zoom Camera
Culling Mask = Default only
UICamera Event Receiver Mask = Default only

4) NGUI Camera
Culling Mask = NGUI
UICamera Event Receiver Mask = NGUI

--------------------
Everything in my 2D Root Folder is on layer NGUI

The gameobject prefab (holding NGUI Button Widget) is on layer NGUI, including children

The character prefab has a empty game object on it with AddUnitHUD.  The prefab is on layer default.  I've tried making the empty game object both on NGUI and Default layers - doesn't make a difference (as I'd expect).

------------------
Finally, the debug log that comes up does in fact reference the NGUI layer, "No Camera found for layer NGUI"

Can you think of what the next step for troubleshooting this is? Thanks!


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI AddUnitHUD and UnitHUD giving me issues
« Reply #3 on: August 07, 2013, 06:09:24 AM »
UICamera.FindCamera is used to find the appropriate camera, and this list is added to in UICamera.Awake. Are you calling your logic before the UICamera.Awake has a chance to execute?

Stevorino

  • Guest
Re: NGUI AddUnitHUD and UnitHUD giving me issues
« Reply #4 on: August 07, 2013, 08:35:06 AM »
Thanks for following up AM!

I copied and pasted the script you put in your stickied healthbar post:  http://www.tasharen.com/forum/index.php?topic=130.msg8010#msg8010

Just instead of using a healthbar widget I'm trying to use a button (and will eventually do a health bar too).



ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI AddUnitHUD and UnitHUD giving me issues
« Reply #5 on: August 08, 2013, 10:34:03 AM »
Well if it can't find a proper UICamera, try to figure out why that is. Debug.Log the number of cameras present, and what layers they are on. I can't tell you what's wrong from here. :P