Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: hellwalker on April 17, 2014, 08:57:02 PM

Title: How can I alter onPress and onClick functions?
Post by: hellwalker on April 17, 2014, 08:57:02 PM
Hey  :D

I was wondering if it is possible to alter button functions.
I'm building a simple joystick with gui and for arrows I want to simulate Input.GetButton behavior with NGUI-s OnPress, and it works, but the change I want to make is that now OnPress will set isDown to false only when you stop holding mouse or finger and I want it to set isDown to false when mouse or finger moves outside the button. So If I touch and hold my finger on arrow buttons and then move my finger (or mouse) completely off the button it is still "pressed" and I want to change this.

For OnClick it waits for you to sort of click and release to register clicking, sort of like ButtonUP, and I want for click to register during initial clicking like Unity's  ButtonDown.

If you could point me to where the script for this functions is within NGUI or if there is way to achieve my task without changing those any tips on that would be awesome too.

Thanks in advance!
Title: Re: How can I alter onPress and onClick functions?
Post by: ArenMook on April 18, 2014, 04:22:21 PM
EventDelegate.Set(button.onClick, YourFunction);
EventDelegate.Add(button.onClick, YourFunction);
EventDelegate.Remove(button.onClick, YourFunction);