59 lines
1.3 KiB
C#
59 lines
1.3 KiB
C#
#if UNITY_EDITOR
|
|
|
|
using Sirenix.OdinInspector.Editor;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace UguiToolkit.Editor.Windows
|
|
{
|
|
public abstract class BaseWindow <T>: OdinEditorWindow, IWindow where T : OdinEditorWindow, IWindow
|
|
{
|
|
[SerializeField, HideInInspector]
|
|
private static T m_window;
|
|
public static T Window => m_window;
|
|
|
|
public static T ShowWindow(WindowArgs args = null)
|
|
{
|
|
CloseWindow();
|
|
m_window = CreateWindow<T>();
|
|
m_window.titleContent = new(m_window.GettitleContent());
|
|
|
|
m_window.Show();
|
|
m_window.Init(args);
|
|
|
|
return m_window;
|
|
}
|
|
|
|
public static void CloseWindow()
|
|
{
|
|
if (m_window)
|
|
{
|
|
m_window.Close();
|
|
m_window = null;
|
|
}
|
|
else
|
|
{
|
|
if (EditorWindow.HasOpenInstances<T>())
|
|
{
|
|
EditorWindow.GetWindow<T>().Close();
|
|
}
|
|
}
|
|
}
|
|
|
|
public virtual string GettitleContent() => "";
|
|
public virtual void Init(WindowArgs args = null) { }
|
|
}
|
|
|
|
public interface IWindow
|
|
{
|
|
string GettitleContent();
|
|
void Init(WindowArgs args = null);
|
|
}
|
|
|
|
public class WindowArgs
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
#endif |