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();
}
}
}