48 lines
1.1 KiB
C#
48 lines
1.1 KiB
C#
using Sirenix.OdinInspector.Editor;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace UguiToolkit.Editor.Windows
|
|
{
|
|
public abstract class BaseWindow <T>: OdinEditorWindow, IWindow where T : OdinEditorWindow, IWindow
|
|
{
|
|
private static T m_window;
|
|
public static T Window => m_window;
|
|
|
|
public static T ShowWindow(WindowArgs args = null)
|
|
{
|
|
if (m_window) m_window.Close();
|
|
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;
|
|
}
|
|
}
|
|
|
|
public virtual string GettitleContent() => "";
|
|
public virtual void Init(WindowArgs args = null) { }
|
|
}
|
|
|
|
public interface IWindow
|
|
{
|
|
string GettitleContent();
|
|
void Init(WindowArgs args = null);
|
|
}
|
|
|
|
public class WindowArgs
|
|
{
|
|
|
|
}
|
|
}
|