12345678910111213141516171819202122232425262728293031323334353637383940 |
- using System.Collections.Generic;
- using UnityEditor;
- using UnityEngine;
- public class SceneEditorWindow : EditorWindow
- {
- List<SceneAsset> m_SceneAssets = new List<SceneAsset>();
- // Add menu item named "Example Window" to the Window menu
- [MenuItem("Build/List Scenes", false, 1)]
- public static void ShowWindow()
- {
- //Show existing window instance. If one doesn't exist, make one.
- EditorWindow.GetWindow(typeof(SceneEditorWindow));
- }
- void OnGUI()
- {
- GUILayout.Space(8);
- if (GUILayout.Button("Search and Add Scene files"))
- {
- List<EditorBuildSettingsScene> editorBuildSettingsScenes = new List<EditorBuildSettingsScene>();
- foreach (var file in System.IO.Directory.EnumerateFiles(".", "*.unity", System.IO.SearchOption.AllDirectories))
- {
- string scenePath = file.Remove(0, 2);
- UnityEngine.Debug.Log(scenePath);
- editorBuildSettingsScenes.Add(new EditorBuildSettingsScene(scenePath, true));
- }
- EditorBuildSettings.scenes = editorBuildSettingsScenes.ToArray();
- }
- GUILayout.Space(8);
- if (GUILayout.Button("Clear Scene files"))
- {
- EditorBuildSettings.scenes = null;
- }
- }
- }
|