Created
May 31, 2017 17:11
-
-
Save FaizanDurrani/fe645a0e661af38ae1a6c54febad710e to your computer and use it in GitHub Desktop.
Creates a new editor window to list all the scenes in your project, Improves workflow if you have a ton of directories and scenes.
This file contains hidden or 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
using UnityEditor; | |
using UnityEditor.SceneManagement; | |
using UnityEngine; | |
public class SceneProjectView : EditorWindow { | |
private GUIStyle alternateColor; | |
private Texture2D tex; | |
[MenuItem("Window/Scene Project View")] | |
public static void Init() | |
{ | |
SceneProjectView window = (SceneProjectView) GetWindow (typeof (SceneProjectView)); | |
window.autoRepaintOnSceneChange = true; | |
window.Show (true); | |
} | |
private Vector2 scrollPosition; | |
private string[] assets = new string[0]; | |
public void OnGUI() | |
{ | |
alternateColor = new GUIStyle () | |
{ | |
normal = new GUIStyleState () | |
{ | |
background = new Texture2D (1, 1) | |
} | |
}; | |
alternateColor.normal.background.SetPixel (0, 0, Color.white); | |
if (assets == null) | |
assets = new string[0]; | |
if (GUILayout.Button ("Refresh")) { | |
string[] guidList = AssetDatabase.FindAssets ("t:Scene", null); | |
assets = new string[guidList.Length]; | |
for (int j = 0; j<guidList.Length; j++) | |
{ | |
assets[j] = AssetDatabase.GUIDToAssetPath (guidList[j]); | |
} | |
} | |
scrollPosition = EditorGUILayout.BeginScrollView (scrollPosition); | |
int i = 0; | |
foreach (string asset in assets) | |
{ | |
string[] scenePath = asset.Split('/'); | |
if (i % 2 == 0) | |
EditorGUILayout.BeginHorizontal (alternateColor); | |
else | |
EditorGUILayout.BeginHorizontal (); | |
GUILayout.Label (AssetDatabase.GetCachedIcon(asset), GUILayout.Width(EditorGUIUtility.singleLineHeight + 2.5f), GUILayout.Height (EditorGUIUtility.singleLineHeight + 2.5f)); | |
if (GUILayout.Button (scenePath[scenePath.Length - 1].Remove (scenePath[scenePath.Length - 1].Length - 6), "Label", GUILayout.MinWidth (100))) | |
EditorGUIUtility.PingObject (AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(asset)); | |
if (GUILayout.Button ("Load", GUILayout.Width(40))) | |
{ | |
EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo (); | |
EditorSceneManager.OpenScene (asset); | |
} | |
EditorGUILayout.EndHorizontal (); | |
i++; | |
} | |
EditorGUILayout.EndScrollView (); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment