- Home /
How to change the Object on UI button
Hey guys! So I have a button
-That has an OnClick feature
-That has an object for the OnClick function selected (the one that lets you choose a script on it to call a function from)
I was curious if there was a way to change the object at run time, or at least access that property from another script.
Sorry for the poor wording, and thanks in advance :D
Answer by Pindwin · Sep 05, 2016 at 09:43 AM
Mhm, yeah. The function called OnClick is C# delegate - OnClick is an event you can hook up to. So, you may write:
OnClick += SomeObject.SomeFunction;
and to stop receiving that event, you write:
OnClick -= SomeObject.SomeFunction;
Your answer
Follow this Question
Related Questions
Unity 5.0.2f1 UI Button OnClick Function 6 Answers
UI Button OnClick Function - How to get name of button that was clicked? 2 Answers
UI Button generated in runtime OnClick event 0 Answers
How do change UI.button onclick states(off, editor and runtime, runtime only) via script? 0 Answers
Functions aren't appearing in the onClick editor..... 1 Answer