Merge pull request 'Update tools window' (#3) from ToolsWindowUpdate into main
Reviewed-on: http://newexceptiongames.dynamic-dns.net:3000/NewExceptionGames/Neg_Utils/pulls/3
This commit is contained in:
commit
46d192ea27
@ -10,6 +10,8 @@ namespace NegUtils.Editor
|
|||||||
[InitializeOnLoad]
|
[InitializeOnLoad]
|
||||||
public class ToolsWindowBase : EditorWindow
|
public class ToolsWindowBase : EditorWindow
|
||||||
{
|
{
|
||||||
|
private const int UnitySceneExtensionLength = 6;
|
||||||
|
|
||||||
static ToolsWindowBase()
|
static ToolsWindowBase()
|
||||||
{
|
{
|
||||||
EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
|
EditorApplication.playModeStateChanged += OnPlayModeStateChanged;
|
||||||
@ -55,19 +57,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 - UnitySceneExtensionLength - 1 ,UnitySceneExtensionLength).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)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user