UP-Viagg-io/Viagg-io/Assets/Packages/MyBT/BTC/Handlers/NamedLoadScene.cs

62 lines
1.4 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MyBT;
using UnityEngine.SceneManagement;
#if UNITY_EDITOR
using UnityEditor;
[CustomEditor(typeof(NamedLoadScene))]
public class NamedLoadSceneInspector : ComponentHandlerInspector
{
}
#endif
[System.Serializable]
public class NamedLoadScene : ComponentHandler
{
public override string TypeLabel()
{
return "LoadScene";
}
public override string ContentLabel()
{
UpdateComponent();
return sceneName;
}
public override void UpdateComponent()
{
base.UpdateComponent();
}
public string sceneName = "1.0-SBB";
public LoadSceneMode loadSceneMode = LoadSceneMode.Single;
IEnumerator LoadYourAsyncScene(string sceneName, LoadSceneMode loadSceneMode)
{
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(sceneName, loadSceneMode);
// Wait until the asynchronous scene fully loads
while (!asyncLoad.isDone)
{
yield return null;
}
}
public override void Run(NodeState nodeState)
{
switch (nodeState)
{
case NodeState.FirstRun:
StartCoroutine(LoadYourAsyncScene(sceneName, loadSceneMode));
break;
case NodeState.Running:
break;
case NodeState.Aborting:
break;
}
}
}