Created
January 5, 2023 17:19
-
-
Save khyperia/88f759c27ceff2eac80a061ebe9b7265 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using UnityEngine; | |
namespace UnityEngine | |
{ | |
public interface ICustomYieldInstruction : IEnumerator | |
{ | |
public bool keepWaiting { get; } | |
object IEnumerator.Current => null; | |
bool IEnumerator.MoveNext() => keepWaiting; | |
void IEnumerator.Reset() | |
{ | |
} | |
} | |
} | |
public class WaitFiveFrames : ICustomYieldInstruction | |
{ | |
private int i; | |
public bool keepWaiting => i++ < 5; | |
} | |
public class Test : MonoBehaviour | |
{ | |
public void Awake() | |
{ | |
StartCoroutine(Coro()); | |
} | |
private IEnumerator Coro() | |
{ | |
Debug.Log(Time.frameCount); | |
yield return new WaitFiveFrames(); | |
Debug.Log(Time.frameCount); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment