void StopTimer() { if (TimerCoroutine != null) { TimerCoroutine.Abort(); TimerCoroutine = null; } }
public override void Init() { // start a quick job ICoroutine quickWork = StartCoroutine(DoWork, 0.2); // Start up a couple of coroutines that will "work" for 10s ICoroutine worker1 = StartCoroutine(DoWork, 10.0); ICoroutine worker2 = StartCoroutine(DoWork, 10.0); worker1.Name = "WorkerOne"; // Default name would be "DoWork" worker2.Name = "WorkerTwo"; // Wait for quickWork to have finished. WaitFor(quickWork); // quickWork.IsAlive will now be false // Abort worker1. worker1.Abort(); // worker1.IsAlive will now be false // Note that it will never log "has finished" // Start up a coroutine that won't do anything until it gets a signal. ICoroutine signalWaiter = StartCoroutine(WaitUntilSignal); // Start a coroutine that will do some "work" then send a signal to signalWaiter. StartCoroutine(WorkThenSignal, 2.0, signalWaiter); WaitForAllCoroutines(); }
void ApplyImpulse() { if (_resetCoroutine != null) { _resetCoroutine.Abort(); _resetCoroutine = null; } // Apply linear impulse force if (_applyLinearImpulse) { _rb.AddLinearImpulse(LinearImpulseDirection * LinearForce); } // Apply angular impulse force if (_applyAngularImpulse) { // Generate a new random angular impulse Vector angularImpulse = new Vector((float)_rng.NextDouble() * AngularVariance.X, (float)_rng.NextDouble() * AngularVariance.Y, (float)_rng.NextDouble() * AngularVariance.Z); // Apply the angular impulse if it is non-zero if (angularImpulse.LengthSquared() > 0.0f) { _rb.AddAngularImpulse(angularImpulse.Normalized() * AngularForce); } } if ((ResetTimeout > 0.0) && (_applyLinearImpulse || _applyAngularImpulse)) { _resetCoroutine = StartCoroutine(ResetAfterTimeout); } }
private void StopInterpolation() { if (interpolationCoroutine != null) { interpolationCoroutine.Abort(); interpolationCoroutine = null; } }
private void StopFadeCoroutine() { if (fadeCoroutine != null) { fadeCoroutine.Abort(); fadeCoroutine = null; } }
public void Dispose() { if (coroutine != null) { coroutine.Abort(); coroutine = null; T temp = default(T); while (WaitQueue.Count > 0) { WaitQueue.Dequeue()(temp, true); } } }
void Disable() { if (TimerSub != null) { TimerSub.Unsubscribe(); TimerSub = null; } if (TimerCoroutine != null) { TimerCoroutine.Abort(); TimerCoroutine = null; } }