监听Prefab的Apply保存事件

写一个新的类,放在Editor文件夹下,代码如下:

using UnityEngine;
using System.Collections;
using UnityEditor;

public class Test : MonoBehaviour {
    [InitializeOnLoadMethod]
    static void StartInitializeOnLoadMethod () 
    {
        PrefabUtility.prefabInstanceUpdated = delegate(GameObject instance
        {
            //prefab保存的路径
            Debug.Log(AssetDatabase.GetAssetPath(PrefabUtility.GetPrefabParent(instance)));
        };
    }
}

你可能感兴趣的:(unity5.0+,unity3d)