Restart#
Control / Restart
Description#
Restarts the execution sequence if the conditions are met
Parameters#
| Name | Description |
|---|---|
| Conditions | The conditions to check |
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Title("Restart")]
[Image(typeof(IconRestart), ColorTheme.Type.Blue)]
[Description("Restarts the execution sequence if the conditions are met")]
[Category("Control/Restart")]
[Parameter("Conditions", "The conditions to check")]
[Keywords("Redo", "Again", "Go", "To", "Goto")]
[NestInnerList(nameof(m_Conditions))]
[Serializable]
public class InstructionCoreRestart : Instruction
{
[SerializeField] private Conditions m_Conditions = new Conditions();
protected override string GetTitle(GameObject source) =>
this.m_Conditions.IsEmpty
? "Restart"
: $"Restart if {this.m_Conditions}";
protected override Awaitable Run(Args args)
{
if (this.m_Conditions.Check(args, Conditions.DEFAULT_OPERATION))
{
this.CurrentResult = InstructionResult.Restart;
}
return Done;
}
}
}