- Home /
Trying to create custom events, best way to attach GameObjects and functions to call?
The title is a little hard to get across what I mean, so I'll explain the current set up.
A Button component can currently have set a GameObject, a string Method and a String Component.
When the button is pressed by the user (think Half-Life - pressing E near it), it gets the Component from the assigned object and runs the method. So for example I can do something like GameObject = main_door, Component = "Door", Method = "Open".
But say I want to add multiple objects/methods to a single button? I can't see a way to pass arrays as SerializedFields, which is ideally what I want to use, so I don't have to keep extending/making extra scripts for every single pressable button.
The only way I can currently see is just having the Button have GameObjectA, GameObjectB, etc... But from a programmer's view, that's horrible.
Your answer
Follow this Question
Related Questions
changing script from key based function to GUI button for dice roll game 1 Answer
Is it wise to add scripts to Unity's Event System? 0 Answers
Calling Update() from Pointer Down not working properly 0 Answers
How to make Buttons communicate with UDP 2 Answers
Button onClick delegate with toggling method assignment 0 Answers