Click or drag to resize

BetterCoroutines Class

A very similar but more performant alternative to Unity's coroutines. A coroutine do not belong to any gameobject and therefore doesn't depend on their life cycle. You can however optionally link the coroutines to a gameobject or component. Which update loop they're part of can be specified when they're started. They also allocate less garbage (especially with the yield instructions). Just as with Unity's coroutines you can yield a WWW and AsyncOperation to wait for them to finish. Instead of using Unity's YieldInstructions you should use the pooled replacements:
Inheritance Hierarchy
SystemObject
  Archon.SwissArmyLib.CoroutinesBetterCoroutines

Namespace:  Archon.SwissArmyLib.Coroutines
Assembly:  Archon.SwissArmyLib (in Archon.SwissArmyLib.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public class BetterCoroutines : IEventListener
Request Example View Source

The BetterCoroutines type exposes the following members.

Methods
  NameDescription
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Destructor.
(Overrides ObjectFinalize.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the type of the current instance.
(Inherited from Object.)
Public methodStatic memberIsPaused
Checks whether a coroutine is currently paused either directly or because of a paused parent.
Public methodStatic memberIsRunning
Checks whether a coroutine with the given ID is running. A paused coroutine is still considered running.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodStatic memberPause
Pauses a coroutine.
Public methodStatic memberSetPaused
Pauses or unpauses a coroutine.
Public methodStatic memberStart(IEnumerator, UpdateLoop)
Starts a new coroutine.
Public methodStatic memberStart(IEnumerator, Int32)
Starts a new coroutine.
Public methodStatic memberStart(IEnumerator, GameObject, UpdateLoop)
Starts a new coroutine and links its lifetime to a gameobject. The coroutine will be stopped when the linked gameobject is disabled or destroyed.
Public methodStatic memberStart(IEnumerator, GameObject, Int32)
Starts a new coroutine and links its lifetime to a gameobject. The coroutine will be stopped when the linked gameobject is disabled or destroyed.
Public methodStatic memberStart(IEnumerator, MonoBehaviour, UpdateLoop)
Starts a new coroutine and links its lifetime to a component. The coroutine will be stopped when the linked component is disabled or destroyed.
Public methodStatic memberStart(IEnumerator, MonoBehaviour, Int32)
Starts a new coroutine and links its lifetime to a component. The coroutine will be stopped when the linked component is disabled or destroyed.
Public methodStatic memberStop
Stops a running coroutine prematurely. This will stop any child coroutines as well.
Public methodStatic memberStopAll
Stops all coroutines.
Public methodStatic memberStopAll(Int32)
Stops all coroutines that are running in the specified update loop.
Public methodStatic memberStopAll(UpdateLoop)
Stops all coroutines that are running in the specified update loop.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodStatic memberUnpause
Unpauses a paused coroutine.
Public methodStatic memberWaitForAsyncOperation
Waits until the specified AsyncOperation is done.
Public methodStatic memberWaitForSeconds
Waits for the specified amount of seconds, either in scaled time (just as Unity's WaitForSeconds) or in unscaled time.
Public methodStatic memberWaitForSecondsRealtime
Waits for the specified amount of seconds in real time. Lighter replacement for WaitForSecondsRealtime.
Public methodStatic memberWaitForWWW
Waits until the specified WWW object has finished.
Public methodStatic memberWaitUntil
Waits until the given predicate returns true.
Public methodStatic memberWaitWhile
Waits until the given predicate returns false.
Top
Fields
  NameDescription
Public fieldStatic memberWaitForEndOfFrame
Suspends a coroutine until the very end of the current frame.
Public fieldStatic memberWaitForOneFrame
Suspends a coroutine for one frame.
Top
See Also