Last active
March 8, 2022 14:36
-
-
Save cosmogonies/4ed7ac8d85f8f69cf2e7 to your computer and use it in GitHub Desktop.
Callback on Apply Prefab (Unity)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEditor; | |
[InitializeOnLoad] | |
internal class PrefabExtension | |
{ | |
static PrefabExtension() | |
{ | |
UnityEditor.PrefabUtility.prefabInstanceUpdated += OnPrefabInstanceUpdate; | |
} | |
static void OnPrefabInstanceUpdate(GameObject instance) | |
{ | |
UnityEngine.Debug.Log("[Callback] Prefab.Apply on instance named :" + instance.name); | |
GameObject prefab = UnityEditor.PrefabUtility.GetPrefabParent(instance) as GameObject; | |
string prefabPath = AssetDatabase.GetAssetPath(prefab); | |
UnityEngine.Debug.Log("@Prefab originPath="+prefabPath); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment