- Home /
How can i use 4.6 delegate lists in my scripts ?
We have such function lists in new 4.6 components like Button, Toggle and etc.
How can i use this in my own scripts ? I want like to have my script, then
public Unity4.6.DelegateList list;
And then access it from editor, droping objects, selecting methods and passing arguments.
EDIT:
add the component (Button, etc.) to your canvas panel, etc.) then drop the object containing the script component you wish to access functions from (where it says 'None') then select them from the pull-down.
make sure the functions are public
too...
yeap, but i don't want a button, i want like
BearDiedScript and make some things on BeadDied() and these thing need to be droped down in such lists, like in Button
you mentioned UI elements and weren't that clear on what you really wanted...
if it's just a delegate that you want then just use a delegate! ...and remember to call it from somewhere.
depends on what you're really trying to do...
Answer by 555ea · Jan 05, 2015 at 02:46 PM
Well, the best solution yet is :
Drop a Button component, make sure it is interactable.
Drop the wanted functions in the Editor on that button.
From any function make a Button Simulation (simulating click actually) by
PointerEventData pointer = new PointerEventData (EventSystemInstance.Instance());
ExecuteEvents.Execute (gameObject, pointer, ExecuteEvents.pointerClickHandler);