Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: basil_11 on July 17, 2013, 02:43:13 AM
-
hi,
im new in NGUI and im a bit confused with the execution hierarchy in UIBUttonMessage onRelease/Onclick
onRelease goes first then the onClick.
Im using UIButonMessage for my buttons to execute functions in my COntroller Script
and I want to prevent clicking buttons at the same time
void OnClickFunction ()
{
if (!GUIManager.canTrigger) {
Debug.Log ("can't click");
return;
}
GUIManager.canTrigger = false;
}
Problem: I dont have way to put the GUIManager.canTrigger = TRUE
im trying the onRelease but onRelease is Executed first :(
can someOne give me advices thanks
-
I'd advise rethinking your approach. The order of NGUI's events is not meant to be changed. A click is pressing and releasing the mouse button on the same object. Unless the button is released, there is no click. Instead of doing what you're doing, set your global "canTrigger" flag somewhere in a remote script, and just check it like you do, but don't set it to 'false' in the click function. Instead set it to 'false' in the same place you set it to 'true' to begin with.
Or better yet -- when you can't click on a button, disable it (UIButton.isEnabled).
-
Hi Aren,
Thanks for the advice,
I can appreciate it more if there are some sort of code attached :)
I'm a bit confused on how I handle clicking events properly just like I said in the issue