Author Topic: Rigidbody in gameobject ignores all OnClick events  (Read 3210 times)

iKonrad

  • Guest
Rigidbody in gameobject ignores all OnClick events
« on: January 01, 2014, 07:50:44 PM »
Hey there
Since I have moved to NGUI 3.x, I've noticed a one (major in my case) thing that has changed.
When I have a simple gameobject with collider (let's say a cube) with a OnClick event attached, it responds correctly to the mouse events. However, once I attach a rigidbody, it ignores all the mouseclicks, hovers etc.

How to solve that?
Thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Rigidbody in gameobject ignores all OnClick events
« Reply #1 on: January 01, 2014, 10:21:09 PM »
UICamera specifies the type of events. By default it's set to "UI", which means it expects to work with widgets. A cube has no widget on it, thus no depth, so NGUI does pick it up, but it will likely be behind another widget due to it having no depth.

You can either attach a UIWidget script to your cube and adjust its depth, or you should switch the UICamera's mode to "World", not "UI".

iKonrad

  • Guest
Re: Rigidbody in gameobject ignores all OnClick events
« Reply #2 on: January 02, 2014, 06:21:15 AM »
Oh, I've found that my Main Camera has been set as "UI" type of camera. I've changed that to "World" and now everything works like a charm.

Thanks and good luck.