private static SceneList BuildList(SceneList list) { if (list.Paths == null) { // Removed scenes still show up in build settings as deleted and are thus still listed here. // Unfortunate but that is better than the alternative (enumerating the scenes) which would allow // selection of scenes that aren't in build settings. list.Paths = new List <string>(SceneManager.sceneCountInBuildSettings); list.Names = new GUIContent[SceneManager.sceneCountInBuildSettings + (list.HasNone ? 1 : 0)]; for (var i = 0; i < SceneManager.sceneCountInBuildSettings; i++) { list.Paths.Add(SceneUtility.GetScenePathByBuildIndex(i)); } var index = 0; var prefix = AssetHelper.FindCommonPath(list.Paths); if (list.HasNone) { list.Names[index++] = new GUIContent("None"); } var thumbnail = AssetPreview.GetMiniTypeThumbnail(typeof(SceneAsset)); foreach (var path in list.Paths) { var scene = path.Substring(prefix.Length, path.Length - prefix.Length - 6); // remove the ".unity" extension list.Names[index++] = new GUIContent(scene, thumbnail); } list.Tree = new SelectionTree(); list.Tree.Add("Scene", list.Names); if (list.HasCreate) { list.Tree.Add("Create", new GUIContent[] { new GUIContent("New Scene", thumbnail) }); } } return(list); }
private static SceneList BuildList(SceneList list) { if (list.Paths == null) { // Removed scenes still show up in build settings as deleted and are thus still listed here. // Unfortunate but that is better than the alternative (enumerating the scenes) which would allow // selection of scenes that aren't in build settings. list.Paths = new List <string>(SceneManager.sceneCountInBuildSettings); list.Names = new GUIContent[SceneManager.sceneCountInBuildSettings + (list.HasNone ? 2 : 0) + (list.HasCreate ? 2 : 0)]; for (var i = 0; i < SceneManager.sceneCountInBuildSettings; i++) { list.Paths.Add(SceneUtility.GetScenePathByBuildIndex(i)); } var index = 0; var prefix = AssetHelper.FindCommonPath(list.Paths); if (list.HasNone) { list.Names[index++] = new GUIContent("None"); list.Names[index++] = new GUIContent(""); } foreach (var path in list.Paths) { var scene = path.Substring(prefix.Length); list.Names[index++] = new GUIContent(scene); } if (list.HasCreate) { list.Names[index++] = new GUIContent(""); list.Names[index++] = new GUIContent("Create Scene"); } } return(list); }