Last active
January 3, 2016 18:59
-
-
Save baobao/8505369 to your computer and use it in GitHub Desktop.
Unityのシーンファイルリストウィンドウ。
全てのシーン、ビルド登録シーンを切り替え可。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Scene List Editor Window | |
/// @author Shunsuke Ohba | |
/// </summary> | |
using UnityEngine; | |
using UnityEditor; | |
using System.IO; | |
using System.Collections; | |
using System.Collections.Generic; | |
namespace Baobao.Editor | |
{ | |
public class SceneList : EditorWindow | |
{ | |
private List<FileInfo> FileList; | |
private bool IsUpdate; | |
private bool IsAllScene; | |
private Vector2 scrollPos; | |
[MenuItem ("Window/Scene List")] | |
static void Init () | |
{ | |
EditorWindow w = EditorWindow.GetWindow<SceneList> (); | |
w.Show (); | |
w.title = "Scene list"; | |
} | |
void OnGUI () | |
{ | |
if (IsUpdate) | |
{ | |
FileList = new List<FileInfo> (); | |
// 取得するシーンの切り替え | |
if (!IsAllScene) | |
{ | |
foreach (var scene in EditorBuildSettings.scenes) | |
{ | |
DirectoryInfo info = new DirectoryInfo (scene.path); | |
FileInfo[] fileList = info.GetFiles ("*.unity"); | |
foreach (var file in fileList) | |
FileList.Add (file); | |
} | |
} | |
else | |
{ | |
List<string> dirList = new List<string> (); | |
GetSubfolders (Application.dataPath, dirList); | |
foreach (var path in dirList) | |
{ | |
DirectoryInfo info = new DirectoryInfo (path); | |
FileInfo[] fileList = info.GetFiles ("*.unity"); | |
foreach (var file in fileList) | |
FileList.Add (file); | |
} | |
} | |
} | |
scrollPos = GUILayout.BeginScrollView (scrollPos); | |
if (FileList != null) | |
foreach (var f in FileList) | |
if (GUILayout.Button (f.Name)) | |
EditorApplication.OpenScene (f.FullName); | |
GUILayout.EndScrollView (); | |
IsUpdate = false; | |
IsAllScene = GUILayout.Toggle (IsAllScene, "GET ALL SCENES"); | |
GUILayout.Space (20f); | |
if (GUILayout.Button("Update", GUILayout.Width (200f))) | |
{ | |
IsUpdate = true; | |
} | |
} | |
private void GetSubfolders(string folderName, List<string> subFolders) | |
{ | |
// Get sub folders | |
foreach (string folder in Directory.GetDirectories(folderName)) | |
{ | |
// add list | |
subFolders.Add(folder); | |
GetSubfolders(folder, subFolders); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment