赞
踩
做个备忘避免忘了,该脚本要放在assets下的editor目录才有效。
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEditor;
- using UnityEditor.SceneManagement;
-
- public class PrefabStateUtil
- {
- [InitializeOnLoadMethod]
- static void RegisterPrefabStageEvents()
- {
- PrefabStateUtil t = new PrefabStateUtil();
-
- PrefabStage.prefabSaving += t.OnSaving;
- PrefabStage.prefabSaved += t.OnSaved;
- PrefabStage.prefabStageClosing += t.OnClosing;
- PrefabStage.prefabStageOpened += t.OnOpend;
- }
-
- void OnSaving(GameObject go)
- {
- Debug.Log("预制正在保存", go.name);
- }
-
- void OnSaved(GameObject go)
- {
- Debug.Log("预制保存完毕", go.name);
- }
-
- void OnOpend(PrefabStage stage)
- {
- Debug.Log("预制被打开", stage.assetPath);
- }
-
- void OnClosing(PrefabStage stage)
- {
- Debug.Log("预制被关闭", stage.assetPath);
- }
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。