Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: sean_microburst on May 06, 2014, 02:32:32 AM
-
How can I create a Script than I can use for a "Set Of Controls". I noticed that in OnClick you can get UICamera.currentTouchId.
Is there a way I can use that to create a 'Script' for a full Menu, instead of creating a script per button?
I am fairly new to NGUI, so this may just be a stupid question.
Thanks,
sean_microburst
-
On Click notification on the buttons can trigger any remote function, so I am not quite sure what you're asking here. Are you asking about the OnClick event? The actual event is sent to a single object by NGUI. Button handles that event and triggers the On Click Notification. The notification can call any remote function, or even several functions as you see fit.
-
Same doubt here.
I have a window with several buttons.
I don't want to put one script in each button to implement his OnClick event.
What I want is to put ONE script at my Window (on top of hierarchy, with childrens buttons) and my buttons will doesn't have none script attached. At the Window script, I want to check which button was clicked and activate an method at my way.
-
You don't need to attach any scripts to use the built-in On Click notification on the UIButton.
-
Well, I'm missing something then.
Can you explain me how do I do this? Several buttons activating different functions without any script attached to they?
Or in my case, only one script in my window?
-
Select your button and examine the UIButton component. Do you see the On Click notification? Drag in your game object that has the script whos method you want to call. Now choose that method in the drop-down list.
-
Drag in your game object that has the script whos method you want to call. Now choose that method in the drop-down list.
I did not understand. Drag the method? Drag what to where? I'm using the 2.6.4 version, and I did not see this 'OnClick notification'.
-
lol,
The version that you use is 1 year old ... you should upgrad your NGUI to the last version, but be careful ... ngui has been reworked since the 3.X.X version, you will have to migrate your work.
-
I can not migrate without rewrite some classes at my project, and this will be very traumatic. For my needs, this version still works (I hope). I'm waiting to Unity 4.6 with the new GUI system, to analyse if will worth migrate to it.
-
But what's easier?
Hacking around in a old NGUI version or migrating the latest version? Hm...
-
For now, it's easier usgin the old version. I have no time to migrate. =/
-
Well, it's solved! ;)
I Added a UICheckbox script to the button.
I created a ComponentManager script and I have attached it to a empty gameobject. This script contains the functions that I need to each button of my window. I used it as the the Eventreceiver on UICheckBoxand of a button and wrote the name of my desired method (implemented on my manager) for this button in the FunctionName field.