I’d like to add an On Value Changed event through an editor script - my toggles are instantiated from a prefab but I need to add an On Value Changed event to them after they are instantiated.
I can’t seem to find this info anywhere - I just need the script equivalent of dragging a gameobject onto the Object slot and selecting the relevant public function.
I’m not sure there is such a thing, if there is I would love to know it too. But to add a listener to a toggle’s onValueChanged would look like this:
ToggleVar.onValueChanged.AddListener((t) => { MethodName(); });
Should that method return a Boolean? I don’t know. Where is the documentation for this sort of thing? I don’t think there is any with code examples.
Yeah I have gotten the functionality I need through the .AddListener function, but it’s all invisible - I wish we could somehow add a new entry into the event list so it’s visible!