Author Topic: Direct interaction with HUDText prefab possible?  (Read 3231 times)

Joe @ ByDesign Games

  • Guest
Direct interaction with HUDText prefab possible?
« on: July 27, 2013, 07:46:09 AM »
Following the example scene, we have each "3D" GameObject that needs this kind of HUD, instantiate a HUD prefab object under the HUDRoot and set its UIFollowTarget to be that object. That works fine.

Problem is, we need to be able to interact with the HUD prefab after it is instantiated.

Think of it like this, following the example scene, need someway to register that we clicked on the floating text after it is created. In our specific case, to be able to click on some element of the HUD prefab instance (not the "3D" GameObject that spawned it) to do something with it (in our case, show more info).

Is this possible?

Asking because when adding a button with UIButtonMessage or even UIForwardEvents to our HUD prefab, and then clicking on it, we're not seeing any response. It's like the clicks are being eaten and nothing happens.

Can HUD elements in this configuration receive OnClick events? If no, how otherwise to have interactive HUD prefabs in a 3D scene?

Any ideas here? We're in a bit of a jam and time is running out!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Direct interaction with HUDText prefab possible?
« Reply #1 on: July 27, 2013, 11:56:21 AM »
Unless you add a collider, there won't be anything there to receive an event.

Joe @ ByDesign Games

  • Guest
Re: Direct interaction with HUDText prefab possible?
« Reply #2 on: July 27, 2013, 11:57:55 AM »
As mentioned we added a button to the HUD prefab, and as you know buttons automatically get created with a collider.

And clicking on it, does nothing.


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Direct interaction with HUDText prefab possible?
« Reply #3 on: July 27, 2013, 12:18:43 PM »
Debug it! Enable debugging on the UICamera to see what's under the mouse. Check all the standard factors of what would cause events to not be executed. It's an NGUI question at this point.

Joe @ ByDesign Games

  • Guest
Re: Direct interaction with HUDText prefab possible?
« Reply #4 on: July 27, 2013, 12:22:53 PM »
You found it!

The UICamera eventReceiverMask wasn't set to the UI layer for some reason (isn't this supposed to be automatic?)

So clicks are now working! Fixed!

Thank you Michael!