Author Topic: How To Make Label touchable  (Read 6439 times)

mtran003

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
How To Make Label touchable
« on: May 10, 2012, 09:15:42 PM »
I have a NGUI label on my game and am trying to make it respond to touch/mouse click events.  My function OnClick is not getting triggered. Can someone help?  I have the UICamera script attached to my camera that's rendering my GUI layer and I have my custom script which contains the function OnClick attached to my label.  I have also attached a box collider to my label and have it sized to cover the entire label text

Nothing is happening.

I am using Javascript.

Thanks. :'(
« Last Edit: May 10, 2012, 10:00:20 PM by mtran003 »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How To Make Label touchable
« Reply #1 on: May 10, 2012, 11:06:40 PM »
There is an NGUI menu command that adds a collider and resizes it properly for you -- NGUI menu -> Add Collider.

Make sure that the UICamera's event mask matches its visible mask.

mtran003

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: How To Make Label touchable
« Reply #2 on: May 11, 2012, 07:08:30 AM »
Yes, I have added the collider using NGUI's menu option and the UICamera mask is the same as the camera and the label I want to receive the touch event.

But nothing is triggering.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How To Make Label touchable
« Reply #3 on: May 11, 2012, 02:39:23 PM »
Do you have "Raycast Hit Triggers" checked in your physics settings?

mtran003

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: How To Make Label touchable
« Reply #4 on: May 11, 2012, 02:49:00 PM »
I found the issue.

Through a process of elimination, it turns out that a second UI grouping that I had (for other uses) which also contains a camera with the UICamera script attached was apparently intercepting the events.  Since it turned out that the second camera was redundant (probably added via the NGUI wizard and I missed it), I deleted it and now the events are being triggered.

Regards.