/// <summary> /// sets the appropriate start value and calculates the diffValue /// </summary> internal void prepareForUse() { if (easeFunction == null) { easeFunction = defaultEaseFunction; } switch (tweenType) { case TweenType.Position: targetValueType = TargetValueType.Vector3; _startVector = transform.position; break; case TweenType.LocalPosition: targetValueType = TargetValueType.Vector3; _startVector = transform.localPosition; break; case TweenType.Scale: targetValueType = TargetValueType.Vector3; _startVector = transform.localScale; break; case TweenType.Rotation: targetValueType = TargetValueType.Vector3; _startVector = transform.rotation.eulerAngles; if (isRelativeTween) { _diffVector = targetVector; } else { _diffVector = new Vector3(Mathf.DeltaAngle(_startVector.x, targetVector.x), Mathf.DeltaAngle(_startVector.y, targetVector.y), Mathf.DeltaAngle(_startVector.z, targetVector.z)); } break; case TweenType.LocalRotation: targetValueType = TargetValueType.Vector3; _startVector = transform.localRotation.eulerAngles; if (isRelativeTween) { _diffVector = targetVector; } else { _diffVector = new Vector3(Mathf.DeltaAngle(_startVector.x, targetVector.x), Mathf.DeltaAngle(_startVector.y, targetVector.y), Mathf.DeltaAngle(_startVector.z, targetVector.z)); } break; case TweenType.RectTransformPosition: targetValueType = TargetValueType.Vector3; _startVector = rectTransform.anchoredPosition3D; break; case TweenType.Color: targetValueType = TargetValueType.Color; break; case TweenType.Action: targetValueType = TargetValueType.None; break; case TweenType.Property: targetValueType = TargetValueType.None; propertyTween.prepareForUse(); break; } _elapsedTime = -delay; // we have to be careful with rotations because we always want to rotate in the shortest angle so we set the diffValue with that in mind if (targetValueType == TargetValueType.Vector3 && tweenType != TweenType.Rotation && tweenType != TweenType.LocalRotation) { if (isRelativeTween) { _diffVector = targetVector; } else { _diffVector = targetVector - _startVector; } } else if (targetValueType == TargetValueType.Color) { _material = transform.GetComponent <Renderer>().material; _startColor = _material.GetColor(materialProperty); if (isRelativeTween) { _diffColor = targetColor; } else { _diffColor = targetColor - _startColor; } } }