Created
November 12, 2013 14:38
-
-
Save jnbt/7431843 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private class FrameQueueWorker<T>{ | |
private List<T> items; | |
private Action<T,int> block; | |
private int i, imax; | |
public FrameQueueWorker(List<T> items, Action<T,int> block){ | |
this.items = items; this.block = block; | |
i = 0; imax = items.Count; | |
} | |
public void Play(){ | |
if(i < imax) nextItem(); | |
} | |
private void nextItem(){ | |
Utils.CoroutineStarter.Instance.Add(processNextItem()); | |
} | |
private IEnumerator deferedNextItem(){ | |
yield return new WaitForEndOfFrame(); | |
nextItem(); | |
} | |
private IEnumerator processNextItem(){ | |
yield return new WaitForEndOfFrame(); | |
block(items[i], i); | |
i++; | |
if(i < imax) Utils.CoroutineStarter.Instance.Add(deferedNextItem()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment