#if UNITY_EDITOR using Sirenix.OdinInspector.Editor; using System; using UguiToolkit.Editor.Windows; using UnityEditor; using UnityEditor.SceneManagement; using UnityEngine; namespace UguiToolkit.Editor { public static class PanelHelper { public static event Action jumpOfGameCameraByCurPos; public static event Action recoverDataSelectionObjCache; [InitializeOnLoadMethod] public static void AddListener() { PrefabStage.prefabStageOpened += OnPrefabStageOpened; PrefabStage.prefabStageClosing += OnPrefabStageClosing; } private static void OnPrefabStageOpened(PrefabStage stage) { var setting = GlobalManager.Instance.setting; if (stage.assetPath == null || !setting || string.IsNullOrEmpty(setting.prefabForUIDirPath) || !stage.assetPath.StartsWith(setting.prefabForUIDirPath)) return; // 打开配置界面 PanelCacheWindow.ShowWindow(new PanelCacheWindow.PanelCacheWindowArgs { stage = stage, }); } private static void OnPrefabStageClosing(PrefabStage stage) { // 关闭界面 PanelCacheWindow.CloseWindow(); EditWindow.CloseWindow(); } /// /// 创建热键 SPACE /// /// [MenuItem("GameObject/拼接助手/应用上次变换 _SPACE", false, 5)] public static void JumpOfGameCameraByCurPos(MenuCommand menuCommand) { if (StageManager.Instance) { if (Selection.activeGameObject) jumpOfGameCameraByCurPos.Invoke(Selection.activeGameObject.transform); Debug.Log("JumpOfGameCameraByCurPos"); } } /// /// 创建热键 CTRL SPACE /// /// [MenuItem("GameObject/拼接助手/恢复子节点位置 %SPACE", false, 6)] public static void RecoverDataSelectionObjCache(MenuCommand menuCommand) { if (StageManager.Instance) { if (Selection.activeGameObject) recoverDataSelectionObjCache.Invoke(Selection.activeGameObject.transform); Debug.Log("RecoverDataSelectionObjCache"); } } } } #endif