public static TweenPlugPathEuler Get() { if (mInstance == null) { mInstance = new TweenPlugPathEuler(); } return(mInstance); }
public override void build(SequenceControl seq, Track track, int index, UnityEngine.Object target) { //allow tracks with just one key if (track.keys.Count == 1) { interp = Interpolation.None; } else if (canTween) { //invalid or in-between keys if (endFrame == -1) { return; } } PropertyTrack propTrack = track as PropertyTrack; string varName = propTrack.getMemberName(); if (string.IsNullOrEmpty(varName)) { Debug.LogError("Animator: No FieldInfo or PropertyInfo set."); return; } PropertyTrack.ValueType valueType = propTrack.valueType; //get component and fill the cached method info Component comp = propTrack.GetTargetComp(target as GameObject); if (comp == null) { return; } propTrack.RefreshData(comp); var time = getTime(seq.take.frameRate); Tweener tween = null; if (interp == Interpolation.None) { tween = GenerateSingleValueTweener(seq, propTrack, time, comp); } else if (interp == Interpolation.Linear || path == null) { //grab end frame var endKey = track.keys[index + 1] as PropertyKey; switch (valueType) { case PropertyTrack.ValueType.Integer: tween = DOTween.To(TweenPluginFactory.CreateInt(), () => System.Convert.ToInt32(val), GenerateSetter <int>(propTrack, comp), System.Convert.ToInt32(endKey.val), time); break; case PropertyTrack.ValueType.Float: tween = DOTween.To(TweenPluginFactory.CreateFloat(), () => System.Convert.ToSingle(val), GenerateSetter <float>(propTrack, comp), System.Convert.ToSingle(endKey.val), time); break; case PropertyTrack.ValueType.Double: tween = DOTween.To(TweenPluginFactory.CreateDouble(), () => val, GenerateSetter <double>(propTrack, comp), endKey.val, time); break; case PropertyTrack.ValueType.Long: tween = DOTween.To(TweenPluginFactory.CreateLong(), () => System.Convert.ToInt64(val), GenerateSetter <long>(propTrack, comp), System.Convert.ToInt64(endKey.val), time); break; case PropertyTrack.ValueType.Vector2: tween = DOTween.To(TweenPluginFactory.CreateVector2(), () => vect2, GenerateSetter <Vector2>(propTrack, comp), endKey.vect2, time); break; case PropertyTrack.ValueType.Vector3: tween = DOTween.To(TweenPluginFactory.CreateVector3(), () => vect3, GenerateSetter <Vector3>(propTrack, comp), endKey.vect3, time); break; case PropertyTrack.ValueType.Color: tween = DOTween.To(TweenPluginFactory.CreateColor(), () => color, GenerateSetter <Color>(propTrack, comp), endKey.color, time); break; case PropertyTrack.ValueType.Rect: tween = DOTween.To(TweenPluginFactory.CreateRect(), () => rect, (x) => GenerateSetter <Rect>(propTrack, comp), endKey.rect, time); break; case PropertyTrack.ValueType.Vector4: tween = DOTween.To(TweenPluginFactory.CreateVector4(), () => vect4, GenerateSetter <Vector4>(propTrack, comp), endKey.vect4, time); break; case PropertyTrack.ValueType.Quaternion: tween = DOTween.To(TweenPluginFactory.CreateQuaternion(), () => quat, GenerateSetter <Quaternion>(propTrack, comp), endKey.quat, time); break; } } else { switch (valueType) { case PropertyTrack.ValueType.Integer: tween = DOTween.To(TweenPlugPathInt.Get(), () => System.Convert.ToInt32(val), GenerateSetter <int>(propTrack, comp), path, time); break; case PropertyTrack.ValueType.Float: tween = DOTween.To(TweenPlugPathFloat.Get(), () => System.Convert.ToSingle(val), GenerateSetter <float>(propTrack, comp), path, time); break; case PropertyTrack.ValueType.Double: tween = DOTween.To(TweenPlugPathDouble.Get(), () => val, GenerateSetter <double>(propTrack, comp), path, time); break; case PropertyTrack.ValueType.Long: tween = DOTween.To(TweenPlugPathLong.Get(), () => System.Convert.ToInt64(val), GenerateSetter <long>(propTrack, comp), path, time); break; case PropertyTrack.ValueType.Vector2: tween = DOTween.To(TweenPlugPathVector2.Get(), () => vect2, GenerateSetter <Vector2>(propTrack, comp), path, time); break; case PropertyTrack.ValueType.Vector3: tween = DOTween.To(TweenPlugPathVector3.Get(), () => vect3, GenerateSetter <Vector3>(propTrack, comp), path, time); break; case PropertyTrack.ValueType.Color: tween = DOTween.To(TweenPlugPathColor.Get(), () => color, GenerateSetter <Color>(propTrack, comp), path, time); break; case PropertyTrack.ValueType.Rect: tween = DOTween.To(TweenPlugPathRect.Get(), () => rect, GenerateSetter <Rect>(propTrack, comp), path, time); break; case PropertyTrack.ValueType.Vector4: tween = DOTween.To(TweenPlugPathVector4.Get(), () => vect4, GenerateSetter <Vector4>(propTrack, comp), path, time); break; case PropertyTrack.ValueType.Quaternion: tween = DOTween.To(TweenPlugPathEuler.Get(), () => quat, GenerateSetter <Quaternion>(propTrack, comp), path, time); break; } } if (tween != null) { if (canTween) { if (hasCustomEase()) { tween.SetEase(easeCurve); } else { tween.SetEase(easeType, amplitude, period); } } seq.Insert(this, tween); } return; }
public override void build(SequenceControl seq, Track track, int index, UnityEngine.Object obj) { //allow tracks with just one key if (track.keys.Count == 1) { interp = Interpolation.None; } else if (canTween) { //invalid or in-between keys if (endFrame == -1) { return; } } Transform trans = obj as Transform; Rigidbody body = trans.GetComponent <Rigidbody>(); Rigidbody2D body2D = !body?trans.GetComponent <Rigidbody2D>() : null; int frameRate = seq.take.frameRate; float time = getTime(frameRate); if (interp == Interpolation.None) { TweenerCore <Quaternion, Quaternion, TWeenPlugNoneOptions> valueTween; if (body2D) { valueTween = DOTween.To(TweenPlugValueSet <Quaternion> .Get(), () => trans.localRotation, (x) => { var parent = trans.parent; if (parent) { body2D.rotation = (x * parent.rotation).eulerAngles.z; } else { body2D.rotation = x.eulerAngles.z; } }, rotation, time); } else if (body) { valueTween = DOTween.To(TweenPlugValueSet <Quaternion> .Get(), () => trans.localRotation, (x) => { var parent = trans.parent; if (parent) { body.rotation = x * parent.rotation; } else { body.rotation = x; } }, rotation, time); } else { valueTween = DOTween.To(TweenPlugValueSet <Quaternion> .Get(), () => trans.localRotation, (x) => trans.localRotation = x, rotation, time); } seq.Insert(this, valueTween); } else if (interp == Interpolation.Linear || path == null) { Quaternion endRotation = (track.keys[index + 1] as RotationKey).rotation; TweenerCore <Quaternion, Quaternion, NoOptions> linearTween; if (body2D) { linearTween = DOTween.To(TweenPluginFactory.CreateQuaternion(), () => rotation, (x) => { var parent = trans.parent; if (parent) { body2D.MoveRotation((x * parent.rotation).eulerAngles.z); } else { body2D.MoveRotation(x.eulerAngles.z); } }, endRotation, time); } else if (body) { linearTween = DOTween.To(TweenPluginFactory.CreateQuaternion(), () => rotation, (x) => { var parent = trans.parent; if (parent) { body.MoveRotation(x * parent.rotation); } else { body.MoveRotation(x); } }, endRotation, time); } else { linearTween = DOTween.To(TweenPluginFactory.CreateQuaternion(), () => rotation, (x) => trans.localRotation = x, endRotation, time); } if (hasCustomEase()) { linearTween.SetEase(easeCurve); } else { linearTween.SetEase(easeType, amplitude, period); } seq.Insert(this, linearTween); } else if (interp == Interpolation.Curve) { DOSetter <Quaternion> setter; if (body2D) { setter = x => { var parent = trans.parent; if (parent) { body2D.MoveRotation((x * parent.rotation).eulerAngles.z); } else { body2D.MoveRotation(x.eulerAngles.z); } } } ; else if (body) { setter = x => { var parent = trans.parent; if (parent) { body.MoveRotation(x * parent.rotation); } else { body.MoveRotation(x); } } } ; else { setter = x => trans.localRotation = x; } var pathTween = DOTween.To(TweenPlugPathEuler.Get(), () => rotation, setter, path, time); if (hasCustomEase()) { pathTween.SetEase(easeCurve); } else { pathTween.SetEase(easeType, amplitude, period); } seq.Insert(this, pathTween); } }