Load Scene#
Scenes / Load Scene
Description#
Loads a scene
Parameters#
| Name | Description |
|---|---|
| Scene | The scene to load |
| Mode | Specifies whether or not to load the scene additively |
| Relocates | A collection of game objects that are moved after loading the scene |
Code#
using System;
using UnityEngine;
using UnityEngine.SceneManagement;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Title("Load Scene")]
[Image(typeof(IconUnity), ColorTheme.Type.TextLight)]
[Description("Loads a scene")]
[Category("Scenes/Load Scene")]
[Parameter("Scene", "The scene to load")]
[Parameter("Mode", "Specifies whether or not to load the scene additively")]
[Parameter("Relocates", "A collection of game objects that are moved after loading the scene")]
[NestOuterList(nameof(m_Relocates))]
[Serializable]
public class InstructionCoreSceneLoad : Instruction
{
[SerializeField] private GetScene m_Scene = new GetScene();
[SerializeField] private LoadSceneMode m_Mode = LoadSceneMode.Single;
[SerializeField] private RoomRelocates m_Relocates = new RoomRelocates();
protected override string GetTitle(GameObject source)
{
return this.m_Mode switch
{
LoadSceneMode.Single => $"Load {TextUtils.ThemeAsKeyword("scene")} {this.m_Scene}",
LoadSceneMode.Additive =>
$"Load {TextUtils.ThemeAsKeyword("additive scene")} {this.m_Scene}",
_ => throw new ArgumentOutOfRangeException()
};
}
protected override Awaitable Run(Args args)
{
int sceneIndex = this.m_Scene.Get(args);
if (sceneIndex >= 0)
{
_ = RoomManager.Load(sceneIndex, this.m_Mode, this.m_Relocates);
}
return Done;
}
}
}