protected override void DoCopy(Track track) { (track as OrientationTrack).obj = obj; }
/// <summary> /// Use sequence to insert callbacks, or some other crap, just don't insert the tweener you are returning! /// target is set if required. index = this key's index in the track /// </summary> public virtual void build(SequenceControl seq, Track track, int index, UnityEngine.Object target) { Debug.LogError("Animator: No override for build."); }
public override void build(SequenceControl seq, Track track, int index, UnityEngine.Object obj) { Transform target = obj as Transform; int frameRate = seq.take.frameRate; //allow tracks with just one key if (track.keys.Count == 1) { interp = Interpolation.None; } var scaleTrack = (ScaleTrack)track; var axis = scaleTrack.axis; if (!canTween) { float timeLength = 1.0f / frameRate; if (axis == AxisFlags.X) { float _x = scale.x; var tweenX = DOTween.To(new TweenPlugValueSet <float>(), () => _x, (x) => { var a = target.localScale; a.x = x; target.localScale = a; }, _x, timeLength); tweenX.plugOptions.SetSequence(seq); seq.Insert(this, tweenX); } else if (axis == AxisFlags.Y) { float _y = scale.y; var tweenY = DOTween.To(new TweenPlugValueSet <float>(), () => _y, (y) => { var a = target.localScale; a.y = y; target.localScale = a; }, _y, timeLength); tweenY.plugOptions.SetSequence(seq); seq.Insert(this, tweenY); } else if (axis == AxisFlags.Z) { float _z = scale.z; var tweenZ = DOTween.To(new TweenPlugValueSet <float>(), () => _z, (z) => { var a = target.localScale; a.z = z; target.localScale = a; }, _z, timeLength); tweenZ.plugOptions.SetSequence(seq); seq.Insert(this, tweenZ); } else if (axis == AxisFlags.All) { var tweenV = DOTween.To(new TweenPlugValueSet <Vector3>(), () => scale, (s) => { target.localScale = s; }, scale, timeLength); tweenV.plugOptions.SetSequence(seq); seq.Insert(this, tweenV); } else { var tweenV = DOTween.To(new TweenPlugValueSet <Vector3>(), () => scale, (s) => { var ls = target.localScale; if ((axis & AxisFlags.X) != AxisFlags.None) { ls.x = s.x; } if ((axis & AxisFlags.Y) != AxisFlags.None) { ls.y = s.y; } if ((axis & AxisFlags.Z) != AxisFlags.None) { ls.z = s.z; } target.localScale = ls; }, scale, timeLength); tweenV.plugOptions.SetSequence(seq); seq.Insert(this, tweenV); } } else if (endFrame == -1) { return; } else { float timeLength = getTime(frameRate); Vector3 endScale = ((ScaleKey)track.keys[index + 1]).scale; Tweener tween; if (axis == AxisFlags.X) { tween = DOTween.To(new FloatPlugin(), () => target.localScale.x, (x) => { var a = target.localScale; a.x = x; target.localScale = a; }, endScale.x, timeLength); } else if (axis == AxisFlags.Y) { tween = DOTween.To(new FloatPlugin(), () => target.localScale.y, (y) => { var a = target.localScale; a.y = y; target.localScale = a; }, endScale.y, timeLength); } else if (axis == AxisFlags.Z) { tween = DOTween.To(new FloatPlugin(), () => target.localScale.z, (z) => { var a = target.localScale; a.z = z; target.localScale = a; }, endScale.z, timeLength); } else if (axis == AxisFlags.All) { tween = DOTween.To(TweenPluginFactory.CreateVector3(), () => target.localScale, (s) => target.localScale = s, endScale, timeLength); } else { tween = DOTween.To(TweenPluginFactory.CreateVector3(), () => target.localScale, (s) => { var ls = target.localScale; if ((axis & AxisFlags.X) != AxisFlags.None) { ls.x = s.x; } if ((axis & AxisFlags.Y) != AxisFlags.None) { ls.y = s.y; } if ((axis & AxisFlags.Z) != AxisFlags.None) { ls.z = s.z; } target.localScale = ls; }, endScale, timeLength); } if (hasCustomEase()) { tween.SetEase(easeCurve); } else { tween.SetEase(easeType, amplitude, period); } seq.Insert(this, tween); } }
public override void build(SequenceControl seq, Track track, int index, UnityEngine.Object target) { PropertyTrack propTrack = track as PropertyTrack; if (endFrame == -1 && canTween && propTrack.canTween) { 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; } string varName = propTrack.getMemberName(); int frameRate = seq.take.frameRate; //change to use setvalue track in AMSequence if (!string.IsNullOrEmpty(varName)) { propTrack.RefreshData(comp); //allow tracks with just one key if (!propTrack.canTween || !canTween || track.keys.Count == 1) { seq.Insert(this, GenerateSingleValueTweener(seq, propTrack, frameRate, comp)); } else { //grab end frame var endKey = track.keys[index + 1] as PropertyKey; if (targetsAreEqual(valueType, endKey)) { return; } Tweener tween = null; PropertyInfo propInfo = propTrack.GetCachedPropertyInfo(); if (propInfo != null) { switch (valueType) { case PropertyTrack.ValueType.Integer: tween = DOTween.To(new IntPlugin(), () => System.Convert.ToInt32(propInfo.GetValue(comp, null)), (x) => propInfo.SetValue(comp, x, null), System.Convert.ToInt32(endKey.val), getTime(frameRate)); break; case PropertyTrack.ValueType.Float: tween = DOTween.To(new FloatPlugin(), () => System.Convert.ToSingle(propInfo.GetValue(comp, null)), (x) => propInfo.SetValue(comp, x, null), System.Convert.ToSingle(endKey.val), getTime(frameRate)); break; case PropertyTrack.ValueType.Double: tween = DOTween.To(new DoublePlugin(), () => System.Convert.ToDouble(propInfo.GetValue(comp, null)), (x) => propInfo.SetValue(comp, x, null), endKey.val, getTime(frameRate)); break; case PropertyTrack.ValueType.Long: tween = DOTween.To(new LongPlugin(), () => System.Convert.ToInt64(propInfo.GetValue(comp, null)), (x) => propInfo.SetValue(comp, x, null), System.Convert.ToInt64(endKey.val), getTime(frameRate)); break; case PropertyTrack.ValueType.Vector2: tween = DOTween.To(TweenPluginFactory.CreateVector2(), () => (Vector2)propInfo.GetValue(comp, null), (x) => propInfo.SetValue(comp, x, null), endKey.vect2, getTime(frameRate)); break; case PropertyTrack.ValueType.Vector3: tween = DOTween.To(TweenPluginFactory.CreateVector3(), () => (Vector3)propInfo.GetValue(comp, null), (x) => propInfo.SetValue(comp, x, null), endKey.vect3, getTime(frameRate)); break; case PropertyTrack.ValueType.Color: tween = DOTween.To(TweenPluginFactory.CreateColor(), () => (Color)propInfo.GetValue(comp, null), (x) => propInfo.SetValue(comp, x, null), endKey.color, getTime(frameRate)); break; case PropertyTrack.ValueType.Rect: tween = DOTween.To(new RectPlugin(), () => (Rect)propInfo.GetValue(comp, null), (x) => propInfo.SetValue(comp, x, null), endKey.rect, getTime(frameRate)); break; case PropertyTrack.ValueType.Vector4: tween = DOTween.To(TweenPluginFactory.CreateVector4(), () => (Vector4)propInfo.GetValue(comp, null), (x) => propInfo.SetValue(comp, x, null), endKey.vect4, getTime(frameRate)); break; case PropertyTrack.ValueType.Quaternion: tween = DOTween.To(new PureQuaternionPlugin(), () => (Quaternion)propInfo.GetValue(comp, null), (x) => propInfo.SetValue(comp, x, null), endKey.quat, getTime(frameRate)); break; } } else { FieldInfo fieldInfo = propTrack.GetCachedFieldInfo(); if (fieldInfo != null) { switch (valueType) { case PropertyTrack.ValueType.Integer: tween = DOTween.To(new IntPlugin(), () => System.Convert.ToInt32(fieldInfo.GetValue(comp)), (x) => fieldInfo.SetValue(comp, x), System.Convert.ToInt32(endKey.val), getTime(frameRate)); break; case PropertyTrack.ValueType.Float: tween = DOTween.To(new FloatPlugin(), () => System.Convert.ToSingle(fieldInfo.GetValue(comp)), (x) => fieldInfo.SetValue(comp, x), System.Convert.ToSingle(endKey.val), getTime(frameRate)); break; case PropertyTrack.ValueType.Double: tween = DOTween.To(new DoublePlugin(), () => System.Convert.ToDouble(fieldInfo.GetValue(comp)), (x) => fieldInfo.SetValue(comp, x), endKey.val, getTime(frameRate)); break; case PropertyTrack.ValueType.Long: tween = DOTween.To(new LongPlugin(), () => System.Convert.ToInt64(fieldInfo.GetValue(comp)), (x) => fieldInfo.SetValue(comp, x), System.Convert.ToInt64(endKey.val), getTime(frameRate)); break; case PropertyTrack.ValueType.Vector2: tween = DOTween.To(TweenPluginFactory.CreateVector2(), () => (Vector2)fieldInfo.GetValue(comp), (x) => fieldInfo.SetValue(comp, x), endKey.vect2, getTime(frameRate)); break; case PropertyTrack.ValueType.Vector3: tween = DOTween.To(TweenPluginFactory.CreateVector3(), () => (Vector3)fieldInfo.GetValue(comp), (x) => fieldInfo.SetValue(comp, x), endKey.vect3, getTime(frameRate)); break; case PropertyTrack.ValueType.Color: tween = DOTween.To(TweenPluginFactory.CreateColor(), () => (Color)fieldInfo.GetValue(comp), (x) => fieldInfo.SetValue(comp, x), endKey.color, getTime(frameRate)); break; case PropertyTrack.ValueType.Rect: tween = DOTween.To(new RectPlugin(), () => (Rect)fieldInfo.GetValue(comp), (x) => fieldInfo.SetValue(comp, x), endKey.rect, getTime(frameRate)); break; case PropertyTrack.ValueType.Vector4: tween = DOTween.To(TweenPluginFactory.CreateVector4(), () => (Vector4)fieldInfo.GetValue(comp), (x) => fieldInfo.SetValue(comp, x), endKey.vect4, getTime(frameRate)); break; case PropertyTrack.ValueType.Quaternion: tween = DOTween.To(new PureQuaternionPlugin(), () => (Quaternion)fieldInfo.GetValue(comp), (x) => fieldInfo.SetValue(comp, x), endKey.quat, getTime(frameRate)); break; } } } if (tween != null) { if (hasCustomEase()) { tween.SetEase(easeCurve); } else { tween.SetEase((Ease)easeType, amplitude, period); } seq.Insert(this, tween); } } } else { Debug.LogError("Animator: No FieldInfo or PropertyInfo set."); } return; }