12using System.Collections.Generic;
18 private int _runningCount = 0;
20 private Queue<TweenInstance> _toRecycle =
new Queue<TweenInstance>();
25 if (_cachedInstance ==
null) {
26 _cachedInstance = FindObjectOfType<TweenRunner>();
27 if (_cachedInstance ==
null) {
28 _cachedInstance =
new GameObject(
"__Tween Runner__").AddComponent<
TweenRunner>();
29 _cachedInstance.gameObject.hideFlags = HideFlags.HideAndDontSave;
32 return _cachedInstance;
37 for (
int i = _runningCount; i-- != 0;) {
41 }
catch (Exception e) {
42 Debug.LogError(
"Error occured inside of tween! Tween has been terminated");
43 Debug.LogException(e);
50 while (_toRecycle.Count > 0) {
52 Assert.IsTrue(
instance.instanceId < 0,
"Should never try to recycle a Tween with a valid instance id.");
54 if (
instance.instanceId == TweenInstance.ID_WAITING_FOR_RECYCLE) {
55 Assert.IsTrue(
instance.runnerIndex == TweenInstance.NOT_RUNNING,
"Should never try to recycle a running Tween.");
69 if (_runningCount >= _runningTweens.Length) {
70 Utils.DoubleCapacity(ref _runningTweens);
73 instance.runnerIndex = _runningCount;
74 _runningTweens[_runningCount++] =
instance;
81 }
else if (
instance.curPercent == 1.0f) {
94 if (_runningCount < 0) {
95 throw new Exception(
"Removed more tweens than were started!");
101 _runningTweens[index] = _runningTweens[_runningCount];
110 }
else if (
instance.curPercent == 0.0f) {
111 if (
instance.OnReachStart !=
null) {
const int ID_WAITING_FOR_RECYCLE
static TweenRunner instance
void ScheduleForRecycle(TweenInstance instance)
void RemoveTween(TweenInstance instance)
void AddTween(TweenInstance instance)