Author Topic: I get OnClick triggering twice for a single UIButton click  (Read 3298 times)

mslinklater

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
I get OnClick triggering twice for a single UIButton click
« on: July 24, 2014, 08:06:32 AM »
Hi - I'm using NGUI in the Unity Editor. I have a simple scene with a camera and a sprite with a UIButton attached. Inside the UIButton I call a notification method on the OnClick event.

Now when I run inside the editor and click the button I get the OnClick event happening twice. One time it is from the button and a second time from the camera.

If I turn off mouse in the camera event sources and click the button I don't get any events coming through at all.

How can I filter out the camera OnClick events ? All I want to know is when the button has been clicked, not when a widget visible by the camera has been clicked too.

Thanks

mslinklater

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: I get OnClick triggering twice for a single UIButton click
« Reply #1 on: July 24, 2014, 08:14:08 AM »
Found it. I was forwarding the OnClick message to an OnClick method inside another component but on the same gameObject. So My OnClick was being triggered once by the standard messaging system and once by the forwarding system. All is now well, sorry for the distraction 8)