31 lines
731 B
C#
31 lines
731 B
C#
using System;
|
|
using System.Collections;
|
|
using UnityEngine;
|
|
|
|
namespace NEG.Utils
|
|
{
|
|
public static class CoroutineUtils
|
|
{
|
|
private static readonly WaitForEndOfFrame WaitForEndOfFrame = new WaitForEndOfFrame();
|
|
|
|
public static IEnumerator WaitForFrames(int count)
|
|
{
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
yield return null;
|
|
}
|
|
}
|
|
|
|
public static IEnumerator ActionAfterEndOfFrame(Action action)
|
|
{
|
|
yield return WaitForEndOfFrame;
|
|
action?.Invoke();
|
|
}
|
|
|
|
public static IEnumerator ActionAtNextFrame(Action action)
|
|
{
|
|
yield return null;
|
|
action?.Invoke();
|
|
}
|
|
}
|
|
} |