Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: nah0y on November 19, 2013, 09:47:23 AM

Title: OnConstantPress event ?
Post by: nah0y on November 19, 2013, 09:47:23 AM
Hi!

It seems weird but... I can't find anywhere an event that will be call every frame while the user is pressing a button. Am I missing it?

Thanks.
Title: Re: OnConstantPress event ?
Post by: N3uRo on November 19, 2013, 12:15:42 PM
Hi!

It seems weird but... I can't find anywhere an event that will be call every frame while the user is pressing a button. Am I missing it?

Thanks.

Workaround...

  1. bool pressed;
  2.  
  3. void OnPress(bool pressed) {
  4.  this.pressed = pressed;
  5. }
  6.  
  7. void OnConstantPress() {
  8.   // Code
  9. }
  10.  
  11. void Update() {
  12.  if (pressed) {
  13.   OnConstantPress();
  14.  }
  15. }
Title: Re: OnConstantPress event ?
Post by: ArenMook on November 19, 2013, 08:33:59 PM
Yeah there is no constant event. Just set a local flag and check it in Update.
Title: Re: OnConstantPress event ?
Post by: nah0y on November 25, 2013, 04:04:46 AM
Thanks to both of you, that's what I did.