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 :smiley:

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;