Is there a callback to detect when a prefab is generated from a gameobject?

I notice via a component which uses OnEnable to log the prefabtype of the object, that during the process of generating a prefab from a gameobject… that the object is converted to a prefabinstance before the prefab is made and selected.

The component needs to be able to make a minor modification to itself during this process to create a guid for the prefab, nullifying the original object guid for the prefab, and update the now linked prefabinstance with that prefab guid (while retaining its’ originating identifier).

Is there a callback or method called I can use to detect that this process of prefab generation is happening?

I do not see any callback for creation from the list of callback in MonoBehaviour but you could do it yourself since you should know where the object is created in your code and simply add the lines you mention right after:

GameObject obj = (GameObject)Instantiate(prefab);
obj.GUID = newGUID;

But to answer your question, it seems the answer is no, there is no callback for creation but there is for destruction (OnDestroy).

It looks like UnityEditor.PrefabUtility.prefabInstanceUpdated will do what you’re looking for.