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

Unload Scene Async#

Scenes / Unload Scene Async

Description#

Unloads a scene asynchronously

Parameters#

Name Description
Scene The scene to unload
Await Determines whether it awaits till the scene has been fully unloaded

Code#

using System;
using UnityEngine;
using UnityEngine.SceneManagement;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Title("Unload Scene Async")]
    [Image(typeof(IconUnity), ColorTheme.Type.TextLight, typeof(BadgeCross))]
    
    [Description("Unloads a scene asynchronously")]
    [Category("Scenes/Unload Scene Async")]
    
    [Parameter("Scene", "The scene to unload")]
    [Parameter("Await", "Determines whether it awaits till the scene has been fully unloaded")]
    
    [Serializable]
    public class InstructionCoreSceneUnloadAsync : Instruction
    {
        [SerializeField] private GetScene m_Scene = new GetScene();
        [SerializeField] private bool m_Await = true;

        protected override string GetTitle(GameObject source) => $"Unload async {this.m_Scene}";

        protected override async Awaitable Run(Args args)
        {
            int sceneIndex = this.m_Scene.Get(args);
            if (sceneIndex < 0) return;
            
            AsyncOperation asyncOperation = SceneManager.UnloadSceneAsync(sceneIndex);
            if (this.m_Await) await asyncOperation;
        }
    }
}
Visual Script logoVisual Script © Catsoft Works 2026. All rights reserved.