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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
#if UNITY_EDITOR
using System.Collections.Generic;
using Mountools.Tools;
using UnityEditor;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace Mountools.LoadingScreen
{
public class LoadingScreenManager : EditorWindow
{
#if MT_L_CHINESE
private static readonly string WindowName = "加载画面管理器";
#endif
#if MT_L_ENGLISH
private static readonly string WindowName = "Loading Screen Manager";
#endif
private static readonly Vector2 WindowMinSize = new(200, 400);
private static readonly Vector2 WindowMaxSize = new(400, 800);
private LoadingScreenPresets _presets;
private Vector2 _scroll;
private string _search = "";
private int _select;
private void OnDrawWindow()
{
// 加载画面
var loadingScreen = LoadingScreen.GetLoadingScreen();
EditorGUI.BeginDisabledGroup(
loadingScreen != null && loadingScreen.isLoading // 若正在加载
);
{
// 搜索
_search = EditorGUILayout.TextField("", _search, "SearchTextField");
// 转场列表
_scroll = EditorGUILayout.BeginScrollView(_scroll, "OL box NoExpand");
{
foreach (var screen in _presets.loadingScreens)
{
if (string.IsNullOrEmpty(_search.Trim()) ||
screen.name.Trim().ToLower().Contains(_search.Trim().ToLower())
)
{
if (GUILayout.Button(screen.name, "TE toolbarbutton"))
LoadingScreenPresets.ChangePreset(screen);
EditorGUILayout.Space(3);
}
}
}
EditorGUILayout.EndScrollView();
}
EditorGUI.EndDisabledGroup();
// 场景跳转
var sceneCount = SceneManager.sceneCountInBuildSettings;
var scenePathList = new List<string>();
for (var i = 0; i < sceneCount; i ++)
{
scenePathList.Add(SceneUtility.GetScenePathByBuildIndex(i));
}
if (loadingScreen != null)
{
EditorGUI.BeginDisabledGroup(
! Application.isPlaying // 不在游玩
);
{
EditorGUILayout.BeginHorizontal();
{
_select = EditorGUILayout.Popup("", _select, scenePathList.ToArray());
// 加载场景
EditorGUI.BeginDisabledGroup(
SceneManager.GetActiveScene().path == scenePathList[_select] || // 需要跳转的为当前场景
loadingScreen.isLoading // 当前场景正在加载
);
{
if (GUILayout.Button(MountoolsLanguage.Lang("加载场景", "Load Scene"),
"TE toolbarbutton"))
{
LoadingScreen.LoadScene(scenePathList[_select]);
}
}
EditorGUI.EndDisabledGroup();
// 复制代码
var copyText = $"LoadingScreen.LoadScene(\"{scenePathList[_select]}\");";
EditorGUI.BeginDisabledGroup(copyText == EditorGUIUtility.systemCopyBuffer);
{
if (GUILayout.Button(MountoolsLanguage.Lang("复制代码", "Copy Code"),
"TE toolbarbutton"))
{
EditorGUIUtility.systemCopyBuffer = copyText;
}
}
EditorGUI.EndDisabledGroup();
}
EditorGUILayout.EndHorizontal();
}
EditorGUI.EndDisabledGroup();
}
}
public static void OpenWindow()
{
var window = GetWindow<LoadingScreenManager>(WindowName);
window.minSize = WindowMinSize;
window.maxSize = WindowMaxSize;
window._presets = LoadingScreenPresets.GetPresets();
window.Show();
}
private void OnGUI() { OnDrawWindow(); }
}
}
#endif
|