using System.Collections; using UnityEngine; namespace X10D.Unity; /// /// Represents a yield instruction that waits for a key to be pressed. /// public readonly struct WaitForKeyDown : IEnumerator { private readonly KeyCode _keyCode; /// /// Initializes a new instance of the struct. /// /// The key to wait for. public WaitForKeyDown(KeyCode keyCode) { _keyCode = keyCode; } /// public object Current { get => _keyCode == KeyCode.None ? Input.anyKeyDown : Input.GetKeyDown(_keyCode); } /// public bool MoveNext() { return !(_keyCode == KeyCode.None ? Input.anyKeyDown : Input.GetKeyDown(_keyCode)); } /// public void Reset() { } }