com.soviby.unity.ui.ugui-to.../Assets/Editor/Windows/IWindow.cs

48 lines
1.1 KiB
C#
Raw Normal View History

2024-10-28 16:31:38 +00:00
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
{
}
}