com.soviby.unity.ui.ugui-to.../Assets/Editor/Helper/PanelHelper.cs

39 lines
1.1 KiB
C#
Raw Normal View History

2024-10-23 17:30:59 +00:00
#if UNITY_EDITOR
2024-10-28 16:31:38 +00:00
using Sirenix.OdinInspector.Editor;
2024-10-23 17:30:59 +00:00
using UguiToolkit.Editor.Windows;
2024-10-08 15:19:05 +00:00
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
namespace UguiToolkit.Editor
{
public static class PanelHelper
{
[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.StartsWith(setting.prefabForUIDirPath)) return;
// 打开配置界面
2024-10-28 16:31:38 +00:00
PanelCacheWindow.ShowWindow(new PanelCacheWindow.PanelCacheWindowArgs
{
stage = stage,
});
2024-10-08 15:19:05 +00:00
}
private static void OnPrefabStageClosing(PrefabStage stage)
{
2024-10-28 16:31:38 +00:00
// 关闭界面
2024-10-08 15:19:05 +00:00
PanelCacheWindow.CloseWindow();
2024-10-28 16:31:38 +00:00
EditWindow.CloseWindow();
2024-10-08 15:19:05 +00:00
}
}
2024-10-23 17:30:59 +00:00
}
#endif