Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: tnbao91original on June 04, 2014, 03:01:27 AM

Title: How to detect when un press a button ?
Post by: tnbao91original on June 04, 2014, 03:01:27 AM
OnPress method only run 2 time when i press and unpress a button. I put a log in OnPress method and it show me 2 time but how can i detect when i unpress ? Any method OnUnPress ?
Title: Re: How to detect when un press a button ?
Post by: Nicki on June 04, 2014, 05:14:12 AM
OnPress has a bool as parameter.

  1. void OnPress(bool pressed)
  2. {
  3. if (pressed){
  4. Debug.Log("You pressed down on "  + gameobject.name, gameobject)
  5. }
  6. else{
  7. Debug.Log("You released on "  + gameobject.name, gameobject)
  8. }
  9. }
Title: Re: How to detect when un press a button ?
Post by: tnbao91original on June 04, 2014, 10:30:09 AM
Solved, thank you for support :)
Title: Re: How to detect when un press a button ?
Post by: Darkmax on June 04, 2014, 12:57:42 PM
Also you can use OnClick() method this is called when your button is released