Hi,
I’m wondering if there is some sort of event or trigger that I can hook into for whenever I drag/drop a prefab into the scene during play mode in the editor.
Thanks.
Hi,
I’m wondering if there is some sort of event or trigger that I can hook into for whenever I drag/drop a prefab into the scene during play mode in the editor.
Thanks.
I just stared at this and didn’t see anything:
So close too…
I wonder if you can do something with Transform.HasChanged checks? Hm.
You could do this:
Add a script to the prefab and use either Start() or OnEnable()
OnEnable()
{
//Do stuff
Debug.Log("I'm a dragged and dropped prefab");
}
As an alternative to drag-drop, you could do this:
Use a manager script and PrefabUtility.InstantiatePrefab
[SerializeField] private GameObject prefab;
public void SpawnPrefab()
{
var myPrefab = PrefabUtility.Instantiate(prefab) as GameObject;
//now you have a reference to the prefab
//trigger an event
}