holopy3/Assets/UniGLTF/DepthFirstScheduler/IEnumeratorExtensions.cs
Lena Biresch 490ef558ef CleanUp
2021-01-28 13:07:52 +01:00

31 lines
769 B
C#

using System.Collections;
using System.Collections.Generic;
namespace
DepthFirstScheduler
{
public static class IEnumeratorExtensions
{
public static void CoroutinetoEnd(this IEnumerator coroutine)
{
var stack = new Stack<IEnumerator>();
stack.Push(coroutine);
while (stack.Count > 0)
{
if (stack.Peek().MoveNext())
{
var nested = stack.Peek().Current as IEnumerator;
if (nested != null)
{
stack.Push(nested);
}
}
else
{
stack.Pop();
}
}
}
}
}