UnityEvent : prefab problem

Hi guys!

I have some trouble using UnityEvent with my prefab.

I have a house that i need to instantiate. And on this house there is a UnityEvent. When i put my house in the scene, i’m able to add an object on the UnityEvent in the inspector. But when i put my House in the prefab folder, my house loose the UnityEvent that i assigned and i can’t put anything more on it. Someone can explain me?

There is no real docs about UnityEvent so i’m a bit confused.

Thx for reply guys!

A prefab can exist in multiple scenes, so if it referenced an object in a particular scene that would not work. You need to take the prefab and put it into your scene and then set the events for that particular instance. If your going to instantiate it at run time then an alternative is to set the events using a script. In short, a prefab can not reference scene objects.

1 Like

Thanks u a lot!

Couldn’t get a better answer! I’m going to use a script then to manage that.

Thanks for the reply!

1 Like