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

Else#

Control / Else

Description#

Executes the Instructions if the previous one failed

Parameters#

Name Description
Instructions The instructions to run

Code#

using System;
using UnityEngine;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Title("Else")]
    [Image(typeof(IconElse), ColorTheme.Type.Blue)]
    
    [Description("Executes the Instructions if the previous one failed")]
    [Category("Control/Else")]
    
    [Parameter("Instructions", "The instructions to run")]
    
    [Keywords("If", "Condition", "Switch")]
    
    [NestOuterList(nameof(m_Instructions))]
    
    [Serializable]
    public class InstructionCoreConditionElse : Instruction
    {
        [SerializeField] private Instructions m_Instructions = new Instructions();

        protected override string GetTitle(GameObject source) => "Else";

        protected override async Awaitable Run(Args args)
        {
            if (!this.PreviousResult.IsSuccess)
            {
                await this.m_Instructions.Run(args, this.ParentCancelToken);
            }
        }

        public override void OnCancel()
        {
            base.OnCancel();
            this.m_Instructions.Cancel();
        }
    }
}
Visual Script logoVisual Script © Catsoft Works 2026. All rights reserved.