From f3f386d4c0ff0c3bbfb01a148d8cf22c8927308f Mon Sep 17 00:00:00 2001 From: Hubert Mattusch Date: Fri, 11 Aug 2023 19:44:44 +0200 Subject: [PATCH 1/2] Update tools window --- Editor/ToolsWindowBase.cs | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/Editor/ToolsWindowBase.cs b/Editor/ToolsWindowBase.cs index de000ad..ae14fb2 100644 --- a/Editor/ToolsWindowBase.cs +++ b/Editor/ToolsWindowBase.cs @@ -55,19 +55,33 @@ namespace NegUtils.Editor private static void ShowScenesList(Rect position) { var menu = new GenericMenu(); - + string path = Application.dataPath + "/Scenes/Production"; - string[] fileInfo = Directory.GetFiles(path, "*.unity"); + + AddFiles(path, path, menu); + + menu.DropDown(position); + } - foreach (string item in fileInfo) + private static void AddFiles(string path, string basePath, GenericMenu menu) + { + string[] fileInfo = Directory.GetFiles(path, "*.unity"); + for (int i = 0; i < fileInfo.Length; i++) { - string s = item; - menu.AddItem(new GUIContent(s.Remove(0, path.Length + 1).Remove(s.Length - path.Length - 7 ,6)), false, () => { + string s = fileInfo[i]; + menu.AddItem(new GUIContent(s.Remove(0, basePath.Length + 1).Remove(s.Length - basePath.Length - 7 ,6).Replace('\\', '/')), false, () => { LoadScene(s); }); + + if(i == fileInfo.Length) continue; menu.AddSeparator(""); } - menu.DropDown(position); + + string[] dirInfo = Directory.GetDirectories(path); + foreach (string dir in dirInfo) + { + AddFiles(dir, basePath, menu); + } } private static void LoadScene(string path) From b7dfa7bffa6b359e1548878f52ee7b3e48a4fc27 Mon Sep 17 00:00:00 2001 From: Hubert Mattusch Date: Fri, 8 Sep 2023 21:57:20 +0200 Subject: [PATCH 2/2] Apply pr changes --- Editor/ToolsWindowBase.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Editor/ToolsWindowBase.cs b/Editor/ToolsWindowBase.cs index ae14fb2..6248f15 100644 --- a/Editor/ToolsWindowBase.cs +++ b/Editor/ToolsWindowBase.cs @@ -10,6 +10,8 @@ namespace NegUtils.Editor [InitializeOnLoad] public class ToolsWindowBase : EditorWindow { + private const int UnitySceneExtensionLength = 6; + static ToolsWindowBase() { EditorApplication.playModeStateChanged += OnPlayModeStateChanged; @@ -69,7 +71,7 @@ namespace NegUtils.Editor for (int i = 0; i < fileInfo.Length; i++) { string s = fileInfo[i]; - menu.AddItem(new GUIContent(s.Remove(0, basePath.Length + 1).Remove(s.Length - basePath.Length - 7 ,6).Replace('\\', '/')), false, () => { + menu.AddItem(new GUIContent(s.Remove(0, basePath.Length + 1).Remove(s.Length - basePath.Length - UnitySceneExtensionLength - 1 ,UnitySceneExtensionLength).Replace('\\', '/')), false, () => { LoadScene(s); });