added 'unload existing' flag to loading individual scene configs so you can load a set of scenes additively instead of replacing all existing scenes. also replaced the defaultinspector with a custom inspector for editing the scene configs
This commit is contained in:
Родитель
7edf93ed6e
Коммит
008538b11a
Двоичные данные
com.unity.film-tv.toolbox/Documentation~/images/EmptyMultiSceneLoader.png
Normal file
Двоичные данные
com.unity.film-tv.toolbox/Documentation~/images/EmptyMultiSceneLoader.png
Normal file
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 28 KiB |
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 52 KiB |
|
@ -1,5 +1,7 @@
|
|||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Unity.FilmTV.Toolbox.MultiScene
|
||||
{
|
||||
|
@ -9,7 +11,9 @@ namespace Unity.FilmTV.Toolbox.MultiScene
|
|||
[CustomEditor(typeof(MultiSceneLoader))]
|
||||
public class MultiSceneLoaderEditor : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
public Dictionary<SceneConfig, bool> foldoutState = new Dictionary<SceneConfig, bool>();
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
var sceneConfig = (MultiSceneLoader)target;
|
||||
|
||||
|
@ -20,7 +24,76 @@ namespace Unity.FilmTV.Toolbox.MultiScene
|
|||
|
||||
GUILayout.Label("Allows you to define sets of scenes that can be loaded either as one 'set' or individually as desired. Useful for defining subsets of a project that different team members can work on independently.", EditorStyles.wordWrappedLabel);
|
||||
|
||||
DrawDefaultInspector(); // TODO: make a proper inspector for the configs so I don't need to use the default inspector
|
||||
GUILayout.Space(15f);
|
||||
|
||||
GUILayout.Label("Config List", EditorStyles.boldLabel);
|
||||
for( var j = 0; j < sceneConfig.config.Count; j++)
|
||||
{
|
||||
var entry = sceneConfig.config[j];
|
||||
if ( foldoutState.ContainsKey( entry))
|
||||
{
|
||||
foldoutState[entry] = EditorGUILayout.Foldout(foldoutState[entry], entry.name);
|
||||
}
|
||||
else
|
||||
{
|
||||
foldoutState.Add(entry, false);
|
||||
foldoutState[entry] = EditorGUILayout.Foldout(foldoutState[entry], entry.name);
|
||||
}
|
||||
|
||||
if( foldoutState[entry])
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Space(10f);
|
||||
GUILayout.BeginVertical();
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
GUILayout.Label("Config name: ", GUILayout.Width(120f));
|
||||
entry.name = GUILayout.TextField(entry.name);
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
// scene list
|
||||
for (var i = 0; i < entry.sceneList.Count; i++)
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
entry.sceneList[i] = EditorGUILayout.ObjectField("Scene:", entry.sceneList[i], typeof(Object), false);
|
||||
if (GUILayout.Button("-", GUILayout.Width(35f)))
|
||||
{
|
||||
entry.sceneList.Remove(entry.sceneList[i]);
|
||||
}
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Add New Scene"))
|
||||
{
|
||||
entry.sceneList.Add(new Object());
|
||||
}
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.Space(15f);
|
||||
if( GUILayout.Button("Remove Config"))
|
||||
{
|
||||
sceneConfig.config.Remove(entry);
|
||||
foldoutState.Remove(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
if( GUILayout.Button("Add new Config"))
|
||||
{
|
||||
var newConfig = new SceneConfig()
|
||||
{
|
||||
name = "New Config"
|
||||
};
|
||||
sceneConfig.config.Add(newConfig);
|
||||
}
|
||||
|
||||
//DrawDefaultInspector(); // TODO: make a proper inspector for the configs so I don't need to use the default inspector
|
||||
|
||||
EditorGUILayout.Space();
|
||||
GUILayout.Label("Load All Scenes", EditorStyles.boldLabel);
|
||||
|
@ -37,7 +110,7 @@ namespace Unity.FilmTV.Toolbox.MultiScene
|
|||
{
|
||||
EditorGUILayout.Space();
|
||||
if (GUILayout.Button("Load " + entry.name + " Scenes", GUILayout.MinHeight(100), GUILayout.Height(50)))
|
||||
sceneConfig.LoadSceneConfig(entry);
|
||||
sceneConfig.LoadSceneConfig(entry, true);
|
||||
GUILayout.Label("Loads ONLY the scenes defined in " + entry.name + ".", EditorStyles.wordWrappedLabel);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,14 +75,15 @@ namespace Unity.FilmTV.Toolbox.MultiScene
|
|||
/// <summary>
|
||||
/// Load a specific scene config
|
||||
/// </summary>
|
||||
public void LoadSceneConfig( SceneConfig config)
|
||||
public void LoadSceneConfig( SceneConfig config, bool unloadExisting)
|
||||
{
|
||||
|
||||
for( int i = 0; i < config.sceneList.Count; i++)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
// load the first scene in single mode
|
||||
LoadScene(config.sceneList[i], false);
|
||||
// if we need to unload existing, then load the first in single mode, otherwise everything is additive
|
||||
LoadScene(config.sceneList[i], !unloadExisting);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -44,12 +44,24 @@ namespace Unity.FilmTV.Toolbox.MultiScene.Samples
|
|||
{
|
||||
Debug.Log("Loading scenes from config : " + thisConfig.name);
|
||||
yield return new WaitForSeconds(1);
|
||||
sceneConfig.LoadSceneConfig(thisConfig);
|
||||
sceneConfig.LoadSceneConfig(thisConfig, true);
|
||||
Debug.Log("Load scenes from config : " + thisConfig.name + " - COMPLETE");
|
||||
yield return new WaitForSeconds(2);
|
||||
}
|
||||
|
||||
Debug.Log("Load individual scene config - COMPLETE");
|
||||
Debug.Log("Loading individual scene configs without unloading existing");
|
||||
|
||||
yield return new WaitForSeconds(1);
|
||||
foreach (var thisConfig in sceneConfig.config)
|
||||
{
|
||||
Debug.Log("Loading scenes from config : " + thisConfig.name);
|
||||
yield return new WaitForSeconds(1);
|
||||
sceneConfig.LoadSceneConfig(thisConfig, false);
|
||||
Debug.Log("Load scenes from config : " + thisConfig.name + " - COMPLETE");
|
||||
yield return new WaitForSeconds(2);
|
||||
}
|
||||
Debug.Log("Load individual scene config without unloading - COMPLETE");
|
||||
|
||||
yield return new WaitForSeconds(1);
|
||||
Debug.Log("Test Runtime Scene loading - COMPLETE");
|
||||
yield return new WaitForSeconds(2);
|
||||
|
|
Загрузка…
Ссылка в новой задаче