AbortableEnumerator
From Unify Community Wiki
(Difference between revisions)
(Created page with "= AbortableEnumerator = Provides an abort mechanism to a coroutine. Wrap the call to the coroutine with this AbortableEnumerator, and call Abort() when you want to abort it. ...") |
m (Removed duplicate heading) |
||
Line 1: | Line 1: | ||
− | |||
− | |||
Provides an abort mechanism to a coroutine. Wrap the call to the coroutine with this AbortableEnumerator, and call Abort() when you want to abort it. | Provides an abort mechanism to a coroutine. Wrap the call to the coroutine with this AbortableEnumerator, and call Abort() when you want to abort it. | ||
Latest revision as of 23:03, 25 December 2013
Provides an abort mechanism to a coroutine. Wrap the call to the coroutine with this AbortableEnumerator, and call Abort() when you want to abort it.
See this answer for usage example.
public class AbortableEnumerator : IEnumerator { protected IEnumerator enumerator; protected bool isAborted; public AbortableEnumerator(IEnumerator enumerator) { this.enumerator = enumerator; } public void Abort() { isAborted = true; } bool IEnumerator.MoveNext () { if (isAborted) return false; else return enumerator.MoveNext (); } void IEnumerator.Reset () { isAborted = false; enumerator.Reset (); } object IEnumerator.Current { get { return enumerator.Current; } } }