0

I am using a prefab which has a button. I have added an object (which is also part of prefab) whose "Show()" method is added as a listener to the button.

When I hit play, and check in inspector, the button listeners are empty and so the button doesn't work. Can anyone help me find why the listeners are getting cleared. I have set the listener setting to Editor and run time.

Jajan
  • 887
  • 3
  • 15
  • 28
  • Are both objects (the one with the button and the referenced by the listener) instances of the prefab already in the scene before you hit play? Are you sure you don't have any code removing the listener? – Hellium Nov 24 '17 at 17:19
  • Yeah.. they are part of same prefab and I haven't written any code to remove listeners. – Jajan Nov 24 '17 at 17:21
  • Instantiate Button prefab, register the events in int. When Object is about to destroy, register the button. See duplicate for how to do this via code – Programmer Nov 24 '17 at 22:08

0 Answers0