Documentation index for AI agents (llms.txt) A Markdown version of every page is available: request the page's source under /docs/, follow the "alternate" link in this page's head, or start from /llms.txt.
Visual Script logo Manual

Load Scene Async#

Scenes / Load Scene Async

Description#

Loads a scene asynchronously

Parameters#

Name Description
Scene The scene to load
Mode Specifies whether or not to load the scene additively
Await Determines whether it awaits till the scene has been fully loaded
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 Async")]
    [Image(typeof(IconUnity), ColorTheme.Type.TextLight, typeof(BadgeSync))]
    
    [Description("Loads a scene asynchronously")]
    [Category("Scenes/Load Scene Async")]
    
    [Parameter("Scene", "The scene to load")]
    [Parameter("Mode", "Specifies whether or not to load the scene additively")]
    [Parameter("Await", "Determines whether it awaits till the scene has been fully loaded")]
    [Parameter("Relocates", "A collection of game objects that are moved after loading the scene")]
    
    [NestOuterList(nameof(m_Relocates))]
    
    [Serializable]
    public class InstructionCoreSceneLoadAsync : Instruction
    {
        [SerializeField] private GetScene m_Scene = new GetScene();
        [SerializeField] private LoadSceneMode m_Mode = LoadSceneMode.Single;
        
        [SerializeField] private bool m_Await = true;
        
        [SerializeField] private RoomRelocates m_Relocates = new RoomRelocates();

        protected override string GetTitle(GameObject source)
        {
            return this.m_Mode switch
            {
                LoadSceneMode.Single => $"Load async {this.m_Scene}",
                LoadSceneMode.Additive =>
                    $"Load async {TextUtils.ThemeAsKeyword("additive")} {this.m_Scene}",
                _ => throw new ArgumentOutOfRangeException()
            };
        }

        protected override async Awaitable Run(Args args)
        {
            int sceneIndex = this.m_Scene.Get(args);
            if (sceneIndex < 0) return;
            
            Awaitable awaitable = RoomManager.LoadAsync(sceneIndex, this.m_Mode, this.m_Relocates);
            if (this.m_Await) await awaitable;
        }
    }
}
Visual Script logoVisual Script © Catsoft Works 2026. All rights reserved.