0.6.2: Added all scenes to scene picker
This commit is contained in:
parent
2a875eda93
commit
17c55cd03c
|
|
@ -29,15 +29,36 @@ namespace Game.NavigationTool.Editor.Tools
|
||||||
EditorBuildSettingsScene[] scenes = EditorBuildSettings.scenes;
|
EditorBuildSettingsScene[] scenes = EditorBuildSettings.scenes;
|
||||||
var listNames = new List<string>(scenes.Length);
|
var listNames = new List<string>(scenes.Length);
|
||||||
var listPaths = new List<string>(scenes.Length);
|
var listPaths = new List<string>(scenes.Length);
|
||||||
|
|
||||||
for (var i = 0; i < scenes.Length; i++)
|
for (var i = 0; i < scenes.Length; i++)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(scenes[i].path))
|
if (string.IsNullOrEmpty(scenes[i].path))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
listNames.Add(Path.GetFileNameWithoutExtension(scenes[i].path));
|
listNames.Add($"{Path.GetFileNameWithoutExtension(scenes[i].path)} (Build Settings)");
|
||||||
listPaths.Add(scenes[i].path);
|
listPaths.Add(scenes[i].path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string[] guids = AssetDatabase.FindAssets("t:scene");
|
||||||
|
int startIndex = listNames.Count;
|
||||||
|
|
||||||
|
for (var i = 0; i < guids.Length; i++)
|
||||||
|
{
|
||||||
|
string path = AssetDatabase.GUIDToAssetPath(guids[i]);
|
||||||
|
var scene = AssetDatabase.LoadAssetAtPath<SceneAsset>(path);
|
||||||
|
|
||||||
|
if (scene == null || listPaths.Contains(path))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
listNames.Add(path.Substring(7, path.Length - 13).Replace('/', '\\'));
|
||||||
|
listPaths.Add(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (startIndex < listNames.Count)
|
||||||
|
{
|
||||||
|
listNames.Insert(startIndex, string.Empty);
|
||||||
|
listPaths.Insert(startIndex, string.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
OPTIONS = listNames.ToArray();
|
OPTIONS = listNames.ToArray();
|
||||||
PATHS = listPaths.ToArray();
|
PATHS = listPaths.ToArray();
|
||||||
|
|
@ -56,14 +77,19 @@ namespace Game.NavigationTool.Editor.Tools
|
||||||
{
|
{
|
||||||
Initialize();
|
Initialize();
|
||||||
int temp = EditorGUI.Popup(rect, SELECTED_INDEX, OPTIONS, styles.popup);
|
int temp = EditorGUI.Popup(rect, SELECTED_INDEX, OPTIONS, styles.popup);
|
||||||
|
|
||||||
if (temp != -1 && temp != SELECTED_INDEX && OPTIONS.Length != 0)
|
if (temp > -1 && temp != SELECTED_INDEX && OPTIONS.Length != 0)
|
||||||
{
|
{
|
||||||
|
string path = PATHS[temp];
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(path))
|
||||||
|
return;
|
||||||
|
|
||||||
SELECTED_INDEX = temp;
|
SELECTED_INDEX = temp;
|
||||||
EditorSceneManager.OpenScene(PATHS[SELECTED_INDEX], OpenSceneMode.Single);
|
EditorSceneManager.OpenScene(PATHS[SELECTED_INDEX], OpenSceneMode.Single);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public float CalculateWidth()
|
public float CalculateWidth()
|
||||||
{
|
{
|
||||||
return 100.0f;
|
return 100.0f;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "com.module.navigationtool",
|
"name": "com.module.navigationtool",
|
||||||
"version": "0.6.1",
|
"version": "0.6.2",
|
||||||
"displayName": "Module.NavigationTool",
|
"displayName": "Module.NavigationTool",
|
||||||
"description": "Support for navigation tools, like favorites, history and toolbars",
|
"description": "Support for navigation tools, like favorites, history and toolbars",
|
||||||
"unity": "2019.2",
|
"unity": "2019.2",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue