Skip to content

Instantly share code, notes, and snippets.

@khyperia
Created January 5, 2023 17:19
Show Gist options
  • Save khyperia/88f759c27ceff2eac80a061ebe9b7265 to your computer and use it in GitHub Desktop.
Save khyperia/88f759c27ceff2eac80a061ebe9b7265 to your computer and use it in GitHub Desktop.
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