/// <summary> /// adds an AbstractTween (Tween, TweenChain or TweenFlow) to the current list of running Tweens /// </summary> public static void addTween(AbstractGoTween tween) { // early out for invalid items if (!tween.isValid()) { return; } // dont add the same tween twice if (_tweens.Contains(tween)) { return; } // check for dupes and handle them before adding the tween. we only need to check for Tweens if (duplicatePropertyRule != GoDuplicatePropertyRuleType.None && tween is GoTween) { // if handleDuplicatePropertiesInTween returns true it indicates we should not add this tween if (handleDuplicatePropertiesInTween(tween as GoTween)) { return; } // if we became invalid after handling dupes dont add the tween if (!tween.isValid()) { return; } } _tweens.Add(tween); // enable ourself if we are not enabled if (instance != null && !instance.enabled) // purposely using the static instace property just once for initialization { _instance.enabled = true; } // if the Tween isn't paused and it is a "from" tween jump directly to the start position if (tween is GoTween && ((GoTween)tween).isFrom && tween.state != GoTweenState.Paused) { tween.update(0); } // should we start up the time scale independent update? if (_instance != null && !_instance._timeScaleIndependentUpdateIsRunning && tween.updateType == GoUpdateType.TimeScaleIndependentUpdate) { _instance.StartCoroutine(_instance.timeScaleIndependentUpdate()); } #if UNITY_EDITOR if (_instance != null) { _instance.gameObject.name = string.Format("GoKit ({0} tweens)", _tweens.Count); } #endif }
public static void addTween(AbstractGoTween tween) { if (tween.isValid() && !_tweens.Contains(tween) && (duplicatePropertyRule == GoDuplicatePropertyRuleType.None || !(tween is GoTween) || (!handleDuplicatePropertiesInTween(tween as GoTween) && tween.isValid()))) { _tweens.Add(tween); if (!instance.enabled) { _instance.enabled = true; } if (tween is GoTween && ((GoTween)tween).isFrom && tween.state != GoTweenState.Paused) { tween.update(0f); } if (!_instance._timeScaleIndependentUpdateIsRunning && tween.updateType == GoUpdateType.TimeScaleIndependentUpdate) { _instance.StartCoroutine(_instance.timeScaleIndependentUpdate()); } } }