Add Coroutine utils
This commit is contained in:
parent
3327290080
commit
b6bb6f639d
31
CoroutineUtils.cs
Normal file
31
CoroutineUtils.cs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
CoroutineUtils.cs.meta
Normal file
11
CoroutineUtils.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 198d3c167abaa734a91e3bcc2dd10079
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Loading…
x
Reference in New Issue
Block a user