- Home /
List of Eventlisteners to add to a Button on demand?
Is it possible to store a list of EventListeners in a list, and then add them to a button on demand via Button.onClick.AddListener?
I'm making a standard RPG dialogue system - the NPC says a line, and then the user picks from a list of Responses. When they click the Response, a bunch of arbitrary "OnClick" callbacks should happen, which the developer can assign.
Which is a better design method - to have a list of those callbacks in my Response class, which I add the the UI.Button that's already on the canvas when the conversation pops up? Or for each Response to have a Button prefab which gets added to the canvas when the conversation pops up? This prefab method seems like it could be a waste of memory/sloppy, but easier.
Your answer
Follow this Question
Related Questions
i want my star () function to work my button is clicked 0 Answers
Can anyone tell me why script is not working? 2 Answers
[Solved] Button OnClick properties are missing after loading the scene 4 Answers
Passing through a GameObject/Function to a button's OnClick 1 Answer
Button doesn't work when returning to scene (android) 1 Answer