Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: alenb on July 17, 2012, 08:20:09 PM
-
Hi All,
Instead of having individual scripts for each NGUI Button I would like to simply reference the button from my main script and check if it has been clicked. Is such a thing possible? I've been banging my head against the table for a day and a half and I cannot for the life of me find any option that allows me to do such a thing.
Please if anyone has any ideas let me know.
Thank you =)
-
Of course. Use the UIEventListener.Get(buttonGameObject).onClick += YourClickCallback;
-
Thank you so much for your reply. It's all working now =)
-
in this case, which is the preferable usage or gives better performance?
UIEventListener.Get(buttonGameObject).onClick += YourClickCallBack
or
setting the button to have a UIButtonMessage script and call YourClickCallBack?
-
From a performance standpoint
UIEventListener.Get(buttonGameObject).onClick += YourClickCallBack
is faster and UIButtonMessage uses SendMessage which is slower then directly calling the function.
-
thanks a lot.
looks like it is time to change the code... :)
-
If you've done it the other way i would say leave it unless your really looking for something to do. Its not THAT much worse...