Wait Until#
Control / Wait Until
Description#
Waits until the condition is true and then continues the execution
Parameters#
| Name | Description |
|---|---|
| Conditions | The conditions to check |
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Title("Wait Until")]
[Image(typeof(IconTimer), ColorTheme.Type.Blue, typeof(BadgeSync))]
[Description("Waits until the condition is true and then continues the execution")]
[Category("Control/Wait Until")]
[Parameter("Conditions", "The conditions to check")]
[Keywords("Hold", "Pause", "Yield")]
[NestInnerList(nameof(m_Conditions))]
[Serializable]
public class InstructionCoreWaitUntil : Instruction
{
[SerializeField]
private Conditions m_Conditions = new Conditions();
protected override string GetTitle(GameObject source) => $"Wait until {this.m_Conditions}";
protected override async Awaitable Run(Args args)
{
while (!this.m_Conditions.Check(args, Conditions.DEFAULT_OPERATION))
{
await this.NextFrame();
}
}
}
}