Author Topic: UIButton EventDelegate list is empty  (Read 1172 times)

Biggix

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 33
    • View Profile
UIButton EventDelegate list is empty
« on: May 15, 2016, 11:37:28 AM »
When I save a working UIButton into a prefab and then instantiate it during runtime in my game, the EventDelegate list (onClick) it was carrying goes empty and thus button doesn't do any actions.

Can you please share a bit of code for the recreation of the EventDelegate list with code after I instantiate it? For example, I need to execute SomeFunction() with SomeParameter that belongs to SomeScript on SomeGameObject.

Or maybe there is some other way to tackle this issue. Thank you!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIButton EventDelegate list is empty
« Reply #1 on: May 18, 2016, 04:48:30 AM »
I'm guessing your event list is referencing an object outside of the button prefab.

This is simply not possible with the way Unity works. It's a limitation of the prefab system and makes perfect sense if you think about it. How can a prefab reference something that exists outside of it?