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 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; } } var matTrack = track as MaterialTrack; var propType = matTrack.propertyType; Material matInst = matTrack.materialInstance; string prop = matTrack.property; int propId = Shader.PropertyToID(prop); int frameRate = seq.take.frameRate; Tweener tween = null; int keyCount = track.keys.Count; float time = getTime(frameRate); if (interp == Interpolation.None) { switch (propType) { case MaterialTrack.ValueType.Float: case MaterialTrack.ValueType.Range: tween = DOTween.To(TweenPlugValueSet <float> .Get(), () => matInst.GetFloat(propId), (x) => matInst.SetFloat(propId, x), val, time); break; case MaterialTrack.ValueType.Vector: tween = DOTween.To(TweenPlugValueSet <Vector4> .Get(), () => matInst.GetVector(propId), (x) => matInst.SetVector(propId, x), vector, time); break; case MaterialTrack.ValueType.Color: tween = DOTween.To(TweenPlugValueSet <Color> .Get(), () => matInst.GetColor(propId), (x) => matInst.SetColor(propId, x), color, time); break; case MaterialTrack.ValueType.TexOfs: tween = DOTween.To(TweenPlugValueSet <Vector2> .Get(), () => matInst.GetTextureOffset(prop), (x) => matInst.SetTextureOffset(prop, x), texOfs, time); break; case MaterialTrack.ValueType.TexScale: tween = DOTween.To(TweenPlugValueSet <Vector2> .Get(), () => matInst.GetTextureScale(prop), (x) => matInst.SetTextureScale(prop, x), texScale, time); break; case MaterialTrack.ValueType.TexEnv: tween = DOTween.To(TweenPlugValueSet <Texture> .Get(), () => matInst.GetTexture(propId), (x) => matInst.SetTexture(propId, x), texture, time); break; } } else if (interp == Interpolation.Linear || path == null) { var endKey = track.keys[index + 1] as MaterialKey; switch (propType) { case MaterialTrack.ValueType.Float: case MaterialTrack.ValueType.Range: tween = DOTween.To(TweenPluginFactory.CreateFloat(), () => val, (x) => matInst.SetFloat(propId, x), endKey.val, time); break; case MaterialTrack.ValueType.Vector: tween = DOTween.To(TweenPluginFactory.CreateVector4(), () => vector, (x) => matInst.SetVector(propId, x), endKey.vector, time); break; case MaterialTrack.ValueType.Color: tween = DOTween.To(TweenPluginFactory.CreateColor(), () => color, (x) => matInst.SetColor(propId, x), endKey.color, time); break; case MaterialTrack.ValueType.TexOfs: tween = DOTween.To(TweenPluginFactory.CreateVector2(), () => texOfs, (x) => matInst.SetTextureOffset(prop, x), endKey.texOfs, time); break; case MaterialTrack.ValueType.TexScale: tween = DOTween.To(TweenPluginFactory.CreateVector2(), () => texScale, (x) => matInst.SetTextureScale(prop, x), endKey.texScale, time); break; } } else { switch (propType) { case MaterialTrack.ValueType.Float: case MaterialTrack.ValueType.Range: tween = DOTween.To(TweenPlugPathFloat.Get(), () => val, (x) => matInst.SetFloat(propId, x), path, time); break; case MaterialTrack.ValueType.Vector: tween = DOTween.To(TweenPlugPathVector4.Get(), () => vector, (x) => matInst.SetVector(propId, x), path, time); break; case MaterialTrack.ValueType.Color: tween = DOTween.To(TweenPlugPathColor.Get(), () => color, (x) => matInst.SetColor(propId, x), path, time); break; case MaterialTrack.ValueType.TexOfs: tween = DOTween.To(TweenPlugPathVector2.Get(), () => texOfs, (x) => matInst.SetTextureOffset(propId, x), path, time); break; case MaterialTrack.ValueType.TexScale: tween = DOTween.To(TweenPlugPathVector2.Get(), () => texScale, (x) => matInst.SetTextureScale(propId, x), path, time); break; } } if (tween != null) { if (canTween) { if (hasCustomEase()) { tween.SetEase(easeCurve); } else { tween.SetEase((Ease)easeType, amplitude, period); } } seq.Insert(this, tween); } }