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

Set Active Scene#

Scenes / Set Active Scene

Description#

Sets a loaded additive scene as the main active one

Note

The scene must have been additively loaded

Parameters#

Name Description
Scene The scene to be set as active

Code#

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

namespace VisualScript.Runtime
{
    [Title("Set Active Scene")]
    [Image(typeof(IconUnity), ColorTheme.Type.Blue)]
    
    [Description("Sets a loaded additive scene as the main active one")]
    [Category("Scenes/Set Active Scene")]
    
    [Parameter("Scene", "The scene to be set as active")]
    
    [Note("The scene must have been additively loaded")]
    
    [Serializable]
    public class InstructionCoreSetActiveScene : Instruction
    {
        [SerializeField] private GetScene m_Scene = new GetScene();

        protected override string GetTitle(GameObject source) => $"Set {this.m_Scene} as active";

        protected override Awaitable Run(Args args)
        {
            int sceneIndex = this.m_Scene.Get(args);
            if (sceneIndex >= 0)
            {
                Scene scene = SceneManager.GetSceneByBuildIndex(sceneIndex);
                if (scene.isLoaded) SceneManager.SetActiveScene(scene);    
            }
            
            return Done;
        }
    }
}
Visual Script logoVisual Script © Catsoft Works 2026. All rights reserved.