SceneWindow.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System.Collections.Generic;
  2. using UnityEditor;
  3. using UnityEngine;
  4. public class SceneEditorWindow : EditorWindow
  5. {
  6. List<SceneAsset> m_SceneAssets = new List<SceneAsset>();
  7. // Add menu item named "Example Window" to the Window menu
  8. [MenuItem("Build/List Scenes", false, 1)]
  9. public static void ShowWindow()
  10. {
  11. //Show existing window instance. If one doesn't exist, make one.
  12. EditorWindow.GetWindow(typeof(SceneEditorWindow));
  13. }
  14. void OnGUI()
  15. {
  16. GUILayout.Space(8);
  17. if (GUILayout.Button("Search and Add Scene files"))
  18. {
  19. List<EditorBuildSettingsScene> editorBuildSettingsScenes = new List<EditorBuildSettingsScene>();
  20. foreach (var file in System.IO.Directory.EnumerateFiles(".", "*.unity", System.IO.SearchOption.AllDirectories))
  21. {
  22. string scenePath = file.Remove(0, 2);
  23. UnityEngine.Debug.Log(scenePath);
  24. editorBuildSettingsScenes.Add(new EditorBuildSettingsScene(scenePath, true));
  25. }
  26. EditorBuildSettings.scenes = editorBuildSettingsScenes.ToArray();
  27. }
  28. GUILayout.Space(8);
  29. if (GUILayout.Button("Clear Scene files"))
  30. {
  31. EditorBuildSettings.scenes = null;
  32. }
  33. }
  34. }