public void ScheduleForRecycle(TweenInstance instance) { Assert.IsTrue(instance.runnerIndex == TweenInstance.NOT_RUNNING, "Should never schedule a running Tween for recycle."); instance.instanceId = TweenInstance.ID_WAITING_FOR_RECYCLE; _toRecycle.Enqueue(instance); }
public void AddTween(TweenInstance instance) { if (_runningCount >= _runningTweens.Length) { Utils.DoubleCapacity(ref _runningTweens); } instance.runnerIndex = _runningCount; _runningTweens[_runningCount++] = instance; //Dispatch events here, right when the tween has started and state is valid if (instance.curPercent == 0.0f) { if (instance.OnLeaveStart != null) { instance.OnLeaveStart(); } } else if (instance.curPercent == 1.0f) { if (instance.OnLeaveEnd != null) { instance.OnLeaveEnd(); } } }
public void RemoveTween(TweenInstance instance) { if (instance.runnerIndex == -1) { return; } --_runningCount; if (_runningCount < 0) { throw new Exception("Removed more tweens than were started!"); } int index = instance.runnerIndex; _runningTweens[_runningCount].runnerIndex = index; _runningTweens[index] = _runningTweens[_runningCount]; instance.runnerIndex = -1; //Dispatch events here, right when tween is stopped and state is valid if (instance.curPercent == 1.0f) { if (instance.OnReachEnd != null) { instance.OnReachEnd(); } } else if (instance.curPercent == 0.0f) { if (instance.OnReachStart != null) { instance.OnReachStart(); } } //Instance might have been re-added in one of the above callbacks if (instance.runnerIndex == -1 && instance.returnToPoolUponStop) { ScheduleForRecycle(instance); } }
public TweenYieldInstruction(TweenInstance instance) { _instance = instance; _instanceId = _instance.instanceId; }