Hey, although I’ve seen similar questions asked and answered, I’m still completely stuck. I am trying to use UnityEventTools.AddPersistentListener
to add a listener to a button in an editor script, but I get an uninformative error stating that The class null does not derive from UnityEngine.Object
I have a function that takes an integer input, and want to add it as an onClick listener as you would do in the editor
Here’s my current buggy attempt (C#) . g is an int, and OpenMenuOf is a method of EnemyListControlScript
`EnemyListControlScript E = GameObject.Find(“EnemyListController”).GetComponent();
Button btn = myButton.transform.GetChild(0).GetComponent();
UnityEventTools.AddPersistentListener(btn.onClick, new UnityAction(delegate { E.OpenMenuOf(g); }));`
Not sure why this doesn’t work any help would be much appreciated, thanks!