Skip to content

Instantly share code, notes, and snippets.

View artnas's full-sized avatar
🐢

Artur Nasiadko artnas

🐢
View GitHub Profile
@artnas
artnas / gist:821beb0c3efbcd43c67f163ea785fef4
Last active May 23, 2022 19:22
Unity3D - Enumerate a collection over time while trying to maintain target framerate
public static class CoroutineUtilities
{
public static IEnumerator EnumerateOverTime(IEnumerator enumerator, Action<object> action)
{
var maxFrameTime = 1f / Application.targetFrameRate * 1000;
var stopWatch = new Stopwatch();
stopWatch.Start();
while (enumerator.MoveNext())