how to pass/transfer unityevent to button?

alt text

I need help.

How can I transfer UnityEvent to other UnityEvent like this button by script?

I don’t want Button to direct mention method but just refer through script.

I have this variable in script that I want to reference

public UnityEvent Action;

and button that i want to pass unityevent to


nvm, I got help from discord server game dev league.

by KanyeWestknight, Dibbie, Pulni

the solution is to use one of these codes

... .AddListener(Action.Invoke);
... .AddListener(() => Action.Invoke());
... .AddListener(delegate { Action.Invoke(); });

mikip0 say that non delegate is better

“Cause you’re not creating a new delegate object, and its not annonymous, so you can remove it as well
The delegate method wont allow you to remove it, cause you hold no reference to the callback after adding the listener”