- Home /
Other
Selecting a function in the editor
I saw this in an asset called 2D Toolkit, but can't figure out how to replicate it for my own scripts.
2D Toolkit has a component for its buttons that allows you to choose a function from a selected gameObject. When you select the gameObject, the component then has a drop-down menu that contains all the public functions for that game object. The selected function then gets called when, say, the button is pushed.
I'd like this same functionality for a 3D button i'm creating. I'd like my 3D button to be able to call any public function from a game object, with both the game object and function selected in the editor.
Any ideas?
I also just found out about Send$$anonymous$$essage and will probably end up using this for now as it seems simpler.
Send$$anonymous$$essage
won't allow you to get all public functions. It will only allow you to call them by name.
Right. For my 3d button i've decided it can just call a specific function in a target object. So i can have a script on the object that has a function "OnButtonDown" and call that function with Send$$anonymous$$essage, and assign the target object in the editor.