AltaCoroutine
A class in Alta.Coroutines, the global namespace.
A wrapper around a Unity coroutine that tracks its state, catches exceptions and supports cancellation and awaiting. Runs on the given MonoBehaviour, or on the global AltaCoroutineHandler singleton if none is given.
- Listed in Other Alta assemblies
- Derived types
EditorCoroutine - Documented in Threads, coroutines and the timeline, Alta assemblies
Constructors
| Member | What it is |
|---|---|
AltaCoroutine() | Creates an AltaCoroutine with default values. |
Fields
4 private and internal fields
Properties
| Member | What it is |
|---|---|
Coroutine Coroutine { get; private set; } | The underlying Unity coroutine once started. |
static bool IsInitialized { get; } | Static: true once the global AltaCoroutineHandler exists. |
Action<Exception> OnError { get; set; } | Called with the exception if the coroutine throws. When unset, the error is logged instead. |
Action OnFinished { get; set; } | Called when the enumerator runs to the end. |
Action OnStopped { get; set; } | Called when the coroutine is stopped or its cancellation token fires. |
AltaCoroutineState State { get; protected set; } | Running, finished, stopped or error. |
protected IEnumerator Enumerator { get; set; } | The enumerator the coroutine steps through. |
2 private and internal properties
| Member | What it is |
|---|---|
private static AltaCoroutineHandler AltaCoroutineHandler { get; } | The AltaCoroutineHandler singleton that runs coroutines with no target object. |
private MonoBehaviour TargetObject { get; set; } | The behaviour the Unity coroutine runs on; defaults to the handler singleton. If it is destroyed, the coroutine stops with it. |
Methods
| Member | What it is |
|---|---|
static AltaCoroutine Create(IEnumerator enumerator, MonoBehaviour targetObject = null, CancellationToken cancellation = null) | Static: makes a coroutine without starting it. Call Start on the result later. |
static void DelayCall(Action call) | Static: runs an action at the end of the current frame (all such calls are batched), or after a number of seconds with the delay overload. |
static void DelayCall(float delaySeconds, Action call) | Static: runs an action at the end of the current frame (all such calls are batched), or after a number of seconds with the delay overload. |
static void DuoDelayCall(Action call) | Static: runs an action after the end of this frame and the next fixed update. |
Task<bool> GetTask() | Returns a task that completes true when finished, false when stopped, or faults on an error. Adding it also replaces the default error log. |
static AltaCoroutine Start(IEnumerator enumerator, MonoBehaviour targetObject = null, CancellationToken cancellation = null) | Static version creates and starts a coroutine. The instance version starts it, warning if it is already running. |
virtual AltaCoroutine Start() | Static version creates and starts a coroutine. The instance version starts it, warning if it is already running. |
virtual void Stop() | Stops a running coroutine and calls OnStopped. |
4 private and internal methods
Used in
Members of other types that take, return or hold a AltaCoroutine:
EffectHandler.unitsToRegen, RecipePlacer.coroutineHandler, ChunkSync.running, RepeatCommandModule.running, CookingPot.checkingForConversionTemperature, FruitNinja.spawningRoutine, EquipmentCustomizationRoom.playerLeftBoundaryChecker, EquipmentCustomizationRoom.poseCheckingDelay, HeatSourceBase.extinguishCoroutine, HeatSourceBase.lightingCoroutine, ActiveNest.coroutine, AnimatedFloatTransitionAiHook.coroutine, StabilizePickupJoint.recreateJointRoutine, PourableContainer.pouringCoroutine, TouchScreenButtonVisual.growRoutine, INetworkEntity.StartCoroutine, NetworkColliderGroup.onConnectDelay, NetworkEntity.StartCoroutine, HapticWhileHeld.haptic, CombatState.getOutOfCombatCoroutine, DeadState.animationCoroutine, DeadState.handleDeathCoroutine, DownedState.deathCountdownRoutine, ShowNames.NameBoardHandler.delayToActivate, ToggleEnemyHealthBars.rotationUpdater, DiscreteStatBarVisual.pingCoroutine, StatBarSimple.changeAnimation, AutoContainerLid.relidCoroutine, BowString.activeCoroutine, BowStringPullbackInputMethod.timeoutCoroutine, BowStringPullbackInputMethod.waitForTime, ButtonCounter.downButtonPressed, ButtonCounter.upButtonPressed, ButtonCounter.waitingForChangeToFinish, CapPickup.checkingPop, CharacterRigPoser.posingAnimation, ColliderGroup.IgnoreCollisionsForDuration, CurveOutput.coroutine, DestroyByTime.destroyCoroutine, DragTrigger.dragUpdater, EquipmentRoomAnimator.boundaryAnimation, EruptAreaAttack.attacking, Fuse.fuseCoroutine, GarbageCollectTimer.runGcCollect, InGameInspector.displayingMessage, ItemShooter.coroutine, MaterialToggler.running, MRK_ActivationLever.columnAnimation, NetworkingUtilities.StartEntityCoroutine, ParticleMeshReplacePooledObject.releaseRoutine, PickupDockingChecker.currentCheckingCoroutine, PickupInteractionScaler.scalingAnimation, PlayerMessageDisplay.messageDisplayCoroutine, PlayerScreenFader.currentFade, PlayerScreenFader.CustomFade, PlayerScreenFader.FadeBackIn, PlayerScreenFader.FadeToBlack, PlayerScreenFader.SetFadedAndFadeBackIn, PlayerSpecialEffectsController.StartDeathAnimation, RendererMaterializerHandler.materializationAnimation and 7 more.