using System.Collections; using UnityEngine; namespace Unity.VisualScripting { /// /// Delays flow by waiting a specified number of seconds. /// [UnitTitle("Wait For Seconds")] [UnitOrder(1)] public class WaitForSecondsUnit : WaitUnit { /// /// The number of seconds to await. /// [DoNotSerialize] [PortLabel("Delay")] public ValueInput seconds { get; private set; } /// /// Whether to ignore the time scale. /// [DoNotSerialize] [PortLabel("Unscaled")] public ValueInput unscaledTime { get; private set; } protected override void Definition() { base.Definition(); seconds = ValueInput(nameof(seconds), 0f); unscaledTime = ValueInput(nameof(unscaledTime), false); Requirement(seconds, enter); Requirement(unscaledTime, enter); } protected override IEnumerator Await(Flow flow) { var seconds = flow.GetValue(this.seconds); if (flow.GetValue(unscaledTime)) { yield return new WaitForSecondsRealtime(seconds); } else { yield return new WaitForSeconds(seconds); } yield return exit; } } }