Author Topic: How do I block click events on a button  (Read 6017 times)

singh029

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 28
    • View Profile
How do I block click events on a button
« on: April 29, 2014, 01:15:11 AM »
The player keeps jumping when i click on the pause button.

Is there a way to display click events on top of a button so only the button event is fired, not the click event?

For screen clicks im using

  1. Input.GetMouseButton(0)
and
  1. Input.mousePosition

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How do I block click events on a button
« Reply #1 on: April 29, 2014, 01:26:06 PM »
Input is Unity. It can't be blocked by NGUI.

You need to use NGUI's events. Rely on the NGUI's event system fully, or not at all. All NGUI's events are blocked by UI elements and other objects properly. Consult the documentation page for UICamera.

singh029

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 28
    • View Profile
Re: How do I block click events on a button
« Reply #2 on: April 30, 2014, 11:42:46 AM »
So can i do something like..

  1. if(UICamera.GetMouse(0))
  2. {
  3. }

If so, is there a static variable to get mouse position?

Or do i need to use the public attribute
  1. Vector2 pos

And im assuming i would need to create a UICamera variable and throw the camera in there, correct?

And do something like..

  1. Vector2 position = uicam.pos;

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How do I block click events on a button
« Reply #3 on: April 30, 2014, 05:51:57 PM »
As I said, use NGUI's events: http://www.tasharen.com/forum/index.php?topic=6711.0

Note the long list of events that NGUI sends out? Use those instead of Input. Inside one of those events UICamera.currentTouch tells you all kinds of information, including the current position of the touch event.