Update tools window

This commit is contained in:
Hubert Mattusch 2023-08-11 19:44:44 +02:00
parent 1f2c251d0c
commit f3f386d4c0

View File

@ -55,19 +55,33 @@ namespace NegUtils.Editor
private static void ShowScenesList(Rect position) private static void ShowScenesList(Rect position)
{ {
var menu = new GenericMenu(); var menu = new GenericMenu();
string path = Application.dataPath + "/Scenes/Production"; 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; string s = fileInfo[i];
menu.AddItem(new GUIContent(s.Remove(0, path.Length + 1).Remove(s.Length - path.Length - 7 ,6)), false, () => { menu.AddItem(new GUIContent(s.Remove(0, basePath.Length + 1).Remove(s.Length - basePath.Length - 7 ,6).Replace('\\', '/')), false, () => {
LoadScene(s); LoadScene(s);
}); });
if(i == fileInfo.Length) continue;
menu.AddSeparator(""); 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) private static void LoadScene(string path)