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 If#

Control / Else If

Description#

Checks a condition if the previous one failed and executes if it's true

Parameters#

Name Description
Conditions The conditions to check
Instructions The instructions to run

Code#

using System;
using UnityEngine;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Title("Else If")]
    [Image(typeof(IconElseIf), ColorTheme.Type.Blue)]
    
    [Description("Checks a condition if the previous one failed and executes if it's true")]
    [Category("Control/Else If")]
    
    [Parameter("Conditions", "The conditions to check")]
    [Parameter("Instructions", "The instructions to run")]
    
    [Keywords("Else", "If", "Condition", "Switch")]
    
    [NestInnerList(nameof(m_Conditions))]
    [NestOuterList(nameof(m_Instructions))]
    
    [Serializable]
    public class InstructionCoreConditionElseIf : Instruction
    {
        [SerializeField] private Conditions m_Conditions = new Conditions();
        [SerializeField] private Instructions m_Instructions = new Instructions();

        protected override string GetTitle(GameObject source) => $"Else if {this.m_Conditions}";

        protected override async Awaitable Run(Args args)
        {
            if (!this.PreviousResult.IsSuccess &&
                this.m_Conditions.Check(args, Conditions.DEFAULT_OPERATION))
            {
                await this.m_Instructions.Run(args, this.ParentCancelToken);
                this.CurrentResult = InstructionResult.Success;
            }
            else
            {
                this.CurrentResult = InstructionResult.Failure;
            }
        }
        
        public override void OnCancel()
        {
            base.OnCancel();
            this.m_Instructions.Cancel();
        }
    }
}
Visual Script logoVisual Script © Catsoft Works 2026. All rights reserved.