Author Topic: UIButton fires twice.  (Read 5114 times)

MaxUylings

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 23
    • View Profile
UIButton fires twice.
« on: September 20, 2012, 05:05:07 AM »
Hello,

We just bought the NGUI extension and have just started to play around with it.
The thing I noticed is that sometimes the UIButton fires twice. And also sometimes it stays on the "Pressed" status of the button. Is there a way to avoid this?

Kind Regards,
Max Uijlings

PhilipC

  • Guest
Re: UIButton fires twice.
« Reply #1 on: September 20, 2012, 09:31:52 AM »
This isnt something i've noticed before unless your using iOS and Unity remote. can you give any more details?

MaxUylings

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: UIButton fires twice.
« Reply #2 on: September 21, 2012, 04:02:52 AM »
I am using IOS with Unity remote. So I assume that what you are suggesting is that when I deploy it to the iPhone this behaviour will not occur?

Kind Regards,
Max Uijlings

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIButton fires twice.
« Reply #3 on: September 21, 2012, 08:16:00 AM »
Yup.

MaxUylings

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: UIButton fires twice.
« Reply #4 on: September 21, 2012, 08:52:29 AM »
Could you maybe tell me why this happens when using the unity remote? This way when I have a similar thing in the future I understand what happens and I can recognise when it is the remote and when it is a real problem.

kind regards

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIButton fires twice.
« Reply #5 on: September 21, 2012, 09:24:48 AM »
Because it sends both mouse and touch events, and NGUI treats both equally. Select the UICamera and uncheck the mouse events.

MaxUylings

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: UIButton fires twice.
« Reply #6 on: September 21, 2012, 09:38:35 AM »
I unchecked the mouse events in the UICamera, but I still have it fire twice sometimes.

MaxUylings

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: UIButton fires twice.
« Reply #7 on: September 21, 2012, 10:32:36 AM »
I just ran the app on my iPhone and the problem was indeed gone. So thanks for the clarification. I now know not to trust the remote to much and will do my testing and debugging on the device again. To bad because the remote was a very nice and fast solution compared to building and running every time.

Kind Regards,
Max
« Last Edit: September 21, 2012, 10:34:28 AM by MaxUylings »

squish007

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: UIButton fires twice.
« Reply #8 on: April 26, 2014, 09:42:45 PM »
i had this same problem, turns out it was because i had the button call an OnClick() function. i changed the function name to ButtonPressed() and it no longer fired twice.