I have a button prefab that needs an OnClick handler added to it. Doing this in the inspector doesn’t work as the scene object doesn’t exist to store as a reference in the prefab and gets removed. Is there a way to add an event in code?
I’ve written a couple of posts on this; here’s a simple example for onClick specifically: Get event sender in event handler (UnityAction)? - Unity Engine - Unity Discussions
All other events require a little bit more TLC. =)