Wait for Frames#
Control / Wait for Frames
Description#
Waits for the specified amount of frames
Parameters#
| Name | Description |
|---|---|
| Frames | The amount of frames to wait |
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Title("Wait for Frames")]
[Image(typeof(IconTimer), ColorTheme.Type.Blue)]
[Description("Waits for the specified amount of frames")]
[Category("Control/Wait for Frames")]
[Parameter("Frames", "The amount of frames to wait")]
[Keywords("Hold", "Pause", "Idle")]
[Serializable]
public class InstructionCoreWaitForFrames : Instruction
{
[SerializeField] private GetInteger m_Frames = new GetInteger(1);
protected override string GetTitle(GameObject source) => $"Wait {this.m_Frames} frames";
protected override async Awaitable Run(Args args)
{
int frames = (int) this.m_Frames.Get(args);
for (int i = 0; i < frames; ++i)
{
await this.NextFrame();
}
}
}
}