-
Notifications
You must be signed in to change notification settings - Fork 341
Expand file tree
/
Copy pathEditorWindowMgr.cs
More file actions
105 lines (95 loc) · 2.93 KB
/
EditorWindowMgr.cs
File metadata and controls
105 lines (95 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace ToolKits
{
/// <summary>
/// 编辑器窗口管理类
/// </summary>
public class EditorWindowMgr
{
/// <summary>
/// 所有打开的编辑器窗口的缓存列表
/// </summary>
private static List<EditorWindowBase> windowList = new List<EditorWindowBase>();
/// <summary>
/// 重复弹出的窗口的优先级
/// </summary>
private static int repeateWindowPriroty = 10;
/// <summary>
/// 添加一个重复弹出的编辑器窗口到缓存中
/// </summary>
/// <param name="window"></param>
public static void AddRepeateWindow(EditorWindowBase window)
{
repeateWindowPriroty++;
window.Priority = repeateWindowPriroty;
AddEditorWindow(window);
}
/// <summary>
/// 从缓存中移除一个重复弹出的编辑器窗口
/// </summary>
/// <param name="window"></param>
public static void RemoveRepeateWindow(EditorWindowBase window)
{
repeateWindowPriroty--;
window.Priority = repeateWindowPriroty;
RemoveEditorWindow(window);
}
/// <summary>
/// 添加一个编辑器窗口到缓存中
/// </summary>
/// <param name="window"></param>
public static void AddEditorWindow(EditorWindowBase window)
{
if (!windowList.Contains(window))
{
windowList.Add(window);
SortWinList();
}
}
/// <summary>
/// 从缓存中移除一个编辑器窗口
/// </summary>
/// <param name="window"></param>
public static void RemoveEditorWindow(EditorWindowBase window)
{
if (windowList.Contains(window))
{
windowList.Remove(window);
SortWinList();
}
}
/// <summary>
/// 管理器强制刷新Window焦点
/// </summary>
public static void FoucusWindow()
{
if (windowList.Count > 0)
{
windowList[windowList.Count - 1].Focus();
}
}
/// <summary>
/// 关闭所有界面,并清理WindowList缓存
/// </summary>
public static void DestoryAllWindow()
{
foreach (EditorWindowBase window in windowList)
{
if (window != null)
{
window.Close();
}
}
windowList.Clear();
}
/// <summary>
/// 对当前缓存窗口列表中的窗口按优先级升序排序
/// </summary>
private static void SortWinList()
{
windowList.Sort((x, y) => { return x.Priority.CompareTo(y.Priority); });
}
}
}