예제 #1
0
        void Awake()
        {
            if (!Application.isPlaying)
            {
                return;
            }

            if (!meta && !_dataHolder)
            {
                foreach (Transform child in transform)
                {
                    if (child.gameObject.name == "_animdata")
                    {
                        _dataHolder = child.gameObject;
                        break;
                    }
                }
            }

            if (_dataHolder)
            {
                _dataHolder.SetActive(false);
            }

            List <AMTakeData> _t = _takes;

            mSequences = new AMSequence[_t.Count];
            for (int i = 0; i < mSequences.Length; i++)
            {
                mSequences[i] = new AMSequence(this, i, _t[i]);
            }
        }
예제 #2
0
 void AMITarget.SequenceTrigger(AMSequence seq, AMKey key, AMTriggerData trigDat)
 {
     if (takeTriggerCallback != null)
     {
         takeTriggerCallback(this, seq.take, key, trigDat);
     }
 }
예제 #3
0
        public override void build(AMSequence seq, AMTrack track, int index, UnityEngine.Object target)
        {
            //float sTime = getWaitTime(seq.take.frameRate, 0.0f);

            Sequence    _seq       = seq.sequence;
            AudioSource _src       = target as AudioSource;
            float       frameRate  = seq.take.frameRate;
            float       frameCount = Mathf.Ceil(audioClip.length * frameRate);

            var tweenV = DOTween.To(new AMPlugValueSetElapsed(), () => 0f, (t) => {
                if (t >= 1f)
                {
                    return;
                }

                float fFrame = Mathf.RoundToInt(t * frameCount);
                _src.time    = (fFrame / frameRate) % audioClip.length;

                _src.pitch = _seq.timeScale;

                if (oneShot)
                {
                    _src.PlayOneShot(audioClip);
                }
                else
                {
                    if ((_src.isPlaying && _src.clip == audioClip))
                    {
                        return;
                    }
                    _src.loop = loop;
                    _src.clip = audioClip;
                    _src.Play();
                }
            }, 0, (loop && !oneShot) ? 1f / frameRate : getTime(seq.take.frameRate));

            tweenV.plugOptions = new AMPlugValueSetOptions(_seq);

            seq.Insert(this, tweenV);

            /*
             * _seq.InsertCallback(sTime, () => {
             *  //don't play when going backwards
             *  if(_seq.isBackwards) return;
             *
             *  _src.pitch = _seq.timeScale;
             *
             *  if(oneShot)
             *      _src.PlayOneShot(audioClip);
             *  else {
             *      if((_src.isPlaying && _src.clip == audioClip)) return;
             *      _src.loop = loop;
             *      _src.clip = audioClip;
             *      _src.Play();
             *  }
             * });*/
        }
예제 #4
0
        public override void build(AMSequence seq, AMTrack track, int index, UnityEngine.Object target)
        {
            if (methodName == null)
            {
                return;
            }

            //get component and fill the cached method info
            Component comp;

            if (seq.target.isMeta)
            {
                if (string.IsNullOrEmpty(componentName))
                {
                    return;
                }
                comp = (target as GameObject).GetComponent(componentName);
            }
            else
            {
                if (component == null)
                {
                    return;
                }
                comp = component;
            }

            float duration = 1.0f / seq.take.frameRate;

            if (useSendMessage)
            {
                if (parameters == null || parameters.Count <= 0)
                {
                    var tween = DOTween.To(new AMPlugValueSetElapsed(), () => 0, (x) => comp.SendMessage(methodName, null, SendMessageOptions.DontRequireReceiver), 0, duration);
                    tween.plugOptions.SetSequence(seq);
                    seq.Insert(this, tween);
                }
                else
                {
                    var tween = DOTween.To(new AMPlugValueSetElapsed(), () => 0, (x) => comp.SendMessage(methodName, parameters[0].toObject(), SendMessageOptions.DontRequireReceiver), 0, duration);
                    tween.plugOptions.SetSequence(seq);
                    seq.Insert(this, tween);
                }
            }
            else
            {
                var method = cachedMethodInfo != null ? cachedMethodInfo : comp.GetType().GetMethod(methodName, GetParamTypes());

                object[] parms = buildParams();

                var tween = DOTween.To(new AMPlugValueSetElapsed(), () => 0, (x) => method.Invoke(comp, parms), 0, duration);
                tween.plugOptions.SetSequence(seq);
                seq.Insert(this, tween);
            }
        }
예제 #5
0
        public override void build(AMSequence seq, AMTrack track, int index, UnityEngine.Object obj)
        {
            if (!obj || (canTween && endFrame == -1))
            {
                return;
            }

            int frameRate = seq.take.frameRate;

            Transform trans = obj as Transform;

            Transform sTarget = GetTarget(seq.target);
            Transform eTarget = canTween ? (track.keys[index + 1] as AMOrientationKey).GetTarget(seq.target) : null;

            var tween = DOTween.To(new FloatPlugin(), () => 0f, (x) => {
                if (sTarget == null && eTarget == null)
                {
                    return;
                }
                else if (sTarget == null)
                {
                    trans.LookAt(eTarget);
                }
                else if (eTarget == null || sTarget == eTarget)
                {
                    trans.LookAt(sTarget);
                }
                else
                {
                    Quaternion s = Quaternion.LookRotation(sTarget.position - trans.position);
                    Quaternion e = Quaternion.LookRotation(eTarget.position - trans.position);

                    trans.rotation = Quaternion.Lerp(s, e, x);
                }
            }, 1f, getTime(frameRate));

            if (sTarget != eTarget)
            {
                if (hasCustomEase())
                {
                    tween.SetEase(easeCurve);
                }
                else
                {
                    tween.SetEase((Ease)easeType, amplitude, period);
                }
            }
            else
            {
                tween.SetEase(Ease.Linear);
            }

            seq.Insert(this, tween);
        }
예제 #6
0
 public override void buildSequenceStart(AMSequence seq)
 {
     //need to add activate game object on start to 'reset' properly during reverse
     if (keys.Count > 0 && keys[0].frame > 0)
     {
         GameObject go    = GetTarget(seq.target) as GameObject;
         var        tween = DG.Tweening.DOTween.To(new AMPlugValueSet <bool>(), () => startActive, (x) => go.SetActive(x), startActive, keys[0].getWaitTime(seq.take.frameRate, 0.0f));
         tween.plugOptions = new AMPlugValueSetOptions(seq.sequence);
         seq.Insert(0f, tween);
     }
 }
예제 #7
0
        public override void build(AMSequence seq, AMTrack track, int index, UnityEngine.Object obj)
        {
            AMTriggerData parm = new AMTriggerData()
            {
                valueString = this.valueString, valueInt = this.valueInt, valueFloat = this.valueFloat
            };
            var tween = DOTween.To(new AMPlugValueSetElapsed(), () => 0, (x) => seq.Trigger(this, parm), 0, 1.0f / seq.take.frameRate);

            tween.plugOptions = new AMPlugValueSetOptions(seq.sequence);
            seq.Insert(this, tween);
        }
예제 #8
0
        public override void build(AMSequence seq, AMTrack track, int index, UnityEngine.Object target)
        {
            GameObject go = target as GameObject;

            if (go == null)
            {
                return;
            }

            var tween = DOTween.To(new AMPlugValueSet <bool>(), () => setActive, (x) => go.SetActive(x), setActive, getTime(seq.take.frameRate));

            tween.plugOptions = new AMPlugValueSetOptions(seq.sequence);
            seq.Insert(this, tween);
        }
예제 #9
0
        void AMITarget.SequenceComplete(AMSequence seq)
        {
            //end camera fade
            if (AMCameraFade.hasInstance())
            {
                AMCameraFade cf = AMCameraFade.getCameraFade();
                cf.playParam = null;
            }

            mLastPlayingTakeIndex = mNowPlayingTakeIndex;
            mNowPlayingTakeIndex  = -1;

            if (takeCompleteCallback != null)
            {
                takeCompleteCallback(this, seq.take);
            }
        }
예제 #10
0
        void Awake()
        {
            if (!Application.isPlaying)
            {
                return;
            }

            _dataHolder.SetActive(false);

            List <AMTakeData> _t = _takes;

            mSequences = new AMSequence[_t.Count];
            for (int i = 0; i < mSequences.Length; i++)
            {
                mSequences[i] = new AMSequence(this, i, _t[i]);
            }
        }
예제 #11
0
        public void PlayAtTime(int index, float time, bool loop = false)
        {
            if (mNowPlayingTakeIndex == index)
            {
                return;
            }

            mLastPlayingTakeIndex = mNowPlayingTakeIndex;

            Pause();

            if (mLastPlayingTakeIndex != -1)
            {
                mSequences[mLastPlayingTakeIndex].take.PlaySwitch(this);     //notify take that we are switching
            }
            AMSequence amSeq = mSequences[index];

            AMTakeData newPlayTake = amSeq.take;

            Sequence seq = amSeq.sequence;

            if (seq == null)
            {
                amSeq.Build(sequenceKillWhenDone, updateType, updateTimeIndependent);
                seq = amSeq.sequence;
            }

            mNowPlayingTakeIndex = index;

            newPlayTake.PlayStart(this, newPlayTake.frameRate * time, 1.0f);     //notify take that we are playing

            if (seq != null)
            {
                /*if(loop) {
                 *  seq.loops = -1;
                 * }
                 * else {
                 *  seq.loops = newPlayTake.numLoop;
                 * }*/

                seq.timeScale = mAnimScale;
                seq.Goto(time, true);
            }
        }
예제 #12
0
        public void SetSequence(AMSequence seq)
        {
            if (mSeq != seq)
            {
                if (mSeq != null)
                {
                    mSeq.stepCompleteCallback -= OnStepComplete;
                }

                mSeq = seq;

                if (mSeq != null)
                {
                    mSeq.stepCompleteCallback += OnStepComplete;
                }
            }

            mLoopCount = 0;
        }
예제 #13
0
        public override void build(AMSequence seq, AMTrack track, int index, UnityEngine.Object obj)
        {
            Transform trans     = obj as Transform;
            int       frameRate = seq.take.frameRate;

            //allow tracks with just one key
            if (track.keys.Count == 1)
            {
                interp = (int)Interpolation.None;
            }

            if (!canTween)
            {
                var tween = DOTween.To(new AMPlugValueSet <Quaternion>(), () => rotation, (x) => trans.localRotation = x, rotation, getTime(frameRate));
                tween.plugOptions.SetSequence(seq);

                seq.Insert(this, tween);
            }
            else if (endFrame == -1)
            {
                return;
            }
            else
            {
                Quaternion endRotation = (track.keys[index + 1] as AMRotationKey).rotation;

                var tween = DOTween.To(new PureQuaternionPlugin(), () => trans.localRotation, (x) => trans.localRotation = x, endRotation, getTime(frameRate));

                if (hasCustomEase())
                {
                    tween.SetEase(easeCurve);
                }
                else
                {
                    tween.SetEase((Ease)easeType, amplitude, period);
                }

                seq.Insert(this, tween);
            }
        }
예제 #14
0
        public override void build(AMSequence seq, AMTrack track, int index, UnityEngine.Object target)
        {
            // if targets are equal do nothing
            if (endFrame == -1 || !hasTargets(seq.target) || targetsAreEqual(seq.target))
            {
                return;
            }

            Camera[] allCameras = (track as AMCameraSwitcherTrack).GetCachedCameras(seq.target);
            int      frameRate  = seq.take.frameRate;
            float    frameCount = getNumberOfFrames(frameRate);
            var      itarget    = seq.target;
            var      _seq       = seq.sequence;

            var tween = DOTween.To(new FloatPlugin(), () => 0f, (x) => {
                AMCameraFade cf = AMCameraFade.getCameraFade();

                AMCameraSwitcherKey.PlayParam param = cf.playParam;
                if (param == null)
                {
                    param = cf.playParam = new AMCameraSwitcherKey.PlayParam();
                }
                param.Apply(this, frameRate, itarget, allCameras, _seq.IsBackwards());

                cf.percent = x / frameCount;
                cf.value   = 1.0f - cf.percent;
            }, frameCount, frameCount / frameRate);

            if (hasCustomEase())
            {
                tween.SetEase(easeCurve);
            }
            else
            {
                tween.SetEase((Ease)easeType, amplitude, period);
            }

            seq.Insert(this, tween);
        }
예제 #15
0
        Tweener GenerateTweener(AMSequence seq, AMPropertyTrack propTrack, float frameRate, Component comp)
        {
            float numFrames = endFrame == -1 ? 1f : (float)(endFrame - frame);
            float time      = numFrames / frameRate;

            switch ((AMPropertyTrack.ValueType)propTrack.valueType)
            {
            case AMPropertyTrack.ValueType.Integer: {
                int _val  = System.Convert.ToInt32(val);
                var tween = DOTween.To(new AMPlugValueSet <int>(), () => _val, GenerateSetter(propTrack, comp, _val), _val, time);
                tween.plugOptions = new AMPlugValueSetOptions(seq.sequence);
                return(tween);
            }

            case AMPropertyTrack.ValueType.Float: {
                float _val  = System.Convert.ToSingle(val);
                var   tween = DOTween.To(new AMPlugValueSet <float>(), () => _val, GenerateSetter(propTrack, comp, _val), _val, time);
                tween.plugOptions = new AMPlugValueSetOptions(seq.sequence);
                return(tween);
            }

            case AMPropertyTrack.ValueType.Double: {
                var tween = DOTween.To(new AMPlugValueSet <double>(), () => val, GenerateSetter(propTrack, comp, val), val, time);
                tween.plugOptions = new AMPlugValueSetOptions(seq.sequence);
                return(tween);
            }

            case AMPropertyTrack.ValueType.Long: {
                long _val  = System.Convert.ToInt64(val);
                var  tween = DOTween.To(new AMPlugValueSet <long>(), () => _val, GenerateSetter(propTrack, comp, _val), _val, time);
                tween.plugOptions = new AMPlugValueSetOptions(seq.sequence);
                return(tween);
            }

            case AMPropertyTrack.ValueType.Vector2: {
                Vector2 _val  = vect2;
                var     tween = DOTween.To(new AMPlugValueSet <Vector2>(), () => _val, GenerateSetter(propTrack, comp, _val), _val, time);
                tween.plugOptions = new AMPlugValueSetOptions(seq.sequence);
                return(tween);
            }

            case AMPropertyTrack.ValueType.Vector3: {
                Vector3 _val  = vect3;
                var     tween = DOTween.To(new AMPlugValueSet <Vector3>(), () => _val, GenerateSetter(propTrack, comp, _val), _val, time);
                tween.plugOptions = new AMPlugValueSetOptions(seq.sequence);
                return(tween);
            }

            case AMPropertyTrack.ValueType.Color: {
                Color _val  = color;
                var   tween = DOTween.To(new AMPlugValueSet <Color>(), () => _val, GenerateSetter(propTrack, comp, _val), _val, time);
                tween.plugOptions = new AMPlugValueSetOptions(seq.sequence);
                return(tween);
            }

            case AMPropertyTrack.ValueType.Rect: {
                Rect _val  = rect;
                var  tween = DOTween.To(new AMPlugValueSet <Rect>(), () => _val, GenerateSetter(propTrack, comp, _val), _val, time);
                tween.plugOptions = new AMPlugValueSetOptions(seq.sequence);
                return(tween);
            }

            case AMPropertyTrack.ValueType.Vector4: {
                var tween = DOTween.To(new AMPlugValueSet <Vector4>(), () => vect4, GenerateSetter(propTrack, comp, vect4), vect4, time);
                tween.plugOptions = new AMPlugValueSetOptions(seq.sequence);
                return(tween);
            }

            case AMPropertyTrack.ValueType.Quaternion: {
                Quaternion _val  = quat;
                var        tween = DOTween.To(new AMPlugValueSet <Quaternion>(), () => _val, GenerateSetter(propTrack, comp, _val), _val, time);
                tween.plugOptions = new AMPlugValueSetOptions(seq.sequence);
                return(tween);
            }

            case AMPropertyTrack.ValueType.Bool: {
                bool _val  = valb;
                var  tween = DOTween.To(new AMPlugValueSet <bool>(), () => _val, GenerateSetter(propTrack, comp, _val), _val, time);
                tween.plugOptions = new AMPlugValueSetOptions(seq.sequence);
                return(tween);
            }

            case AMPropertyTrack.ValueType.String: {
                var tween = DOTween.To(new AMPlugValueSet <string>(), () => valString, GenerateSetter(propTrack, comp, valString), valString, time);
                tween.plugOptions = new AMPlugValueSetOptions(seq.sequence);
                return(tween);
            }

            case AMPropertyTrack.ValueType.Sprite: {
                var spriteRenderer = comp as SpriteRenderer;
                var _val           = valObj as Sprite;
                var tween          = DOTween.To(new AMPlugValueSet <Sprite>(), () => _val, (x) => spriteRenderer.sprite = x, _val, time);
                tween.plugOptions = new AMPlugValueSetOptions(seq.sequence);
                return(tween);
            }

            case AMPropertyTrack.ValueType.Enum: {
                System.Type infType = propTrack.GetCachedInfoType(seq.target);
                object      enumVal = infType != null?System.Enum.ToObject(infType, (int)val) : null;

                if (enumVal != null)
                {
                    var tween = DOTween.To(new AMPlugValueSet <object>(), () => enumVal, GenerateSetter(propTrack, comp, enumVal), enumVal, time);
                    tween.plugOptions = new AMPlugValueSetOptions(seq.sequence);
                    return(tween);
                }
                else
                {
                    Debug.LogError("Invalid enum value.");
                    break;
                }
            }
            }
            return(null); //no type match
        }
예제 #16
0
 /// <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(AMSequence seq, AMTrack track, int index, UnityEngine.Object target)
 {
     Debug.LogError("Animator: No override for build.");
 }
예제 #17
0
 public override void buildSequenceStart(AMSequence sequence)
 {
     //cache material instance
     Init(sequence.target);
 }
예제 #18
0
 public virtual void buildSequenceStart(AMSequence sequence)
 {
 }
예제 #19
0
        public override void build(AMSequence seq, AMTrack track, int index, UnityEngine.Object target)
        {
            AMPropertyTrack propTrack = track as AMPropertyTrack;

            if (endFrame == -1 && canTween && propTrack.canTween)
            {
                return;
            }

            int 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, GenerateTweener(seq, propTrack, frameRate, comp));
                }
                else
                {
                    //grab end frame
                    AMPropertyKey endKey = track.keys[index + 1] as AMPropertyKey;

                    if (targetsAreEqual(valueType, endKey))
                    {
                        return;
                    }

                    Tweener tween = null;

                    PropertyInfo propInfo = propTrack.GetCachedPropertyInfo();
                    if (propInfo != null)
                    {
                        switch ((AMPropertyTrack.ValueType)valueType)
                        {
                        case AMPropertyTrack.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 AMPropertyTrack.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 AMPropertyTrack.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 AMPropertyTrack.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 AMPropertyTrack.ValueType.Vector2:
                            tween = DOTween.To(new Vector2Plugin(), () => (Vector2)propInfo.GetValue(comp, null), (x) => propInfo.SetValue(comp, x, null), endKey.vect2, getTime(frameRate)); break;

                        case AMPropertyTrack.ValueType.Vector3:
                            tween = DOTween.To(new Vector3Plugin(), () => (Vector3)propInfo.GetValue(comp, null), (x) => propInfo.SetValue(comp, x, null), endKey.vect3, getTime(frameRate)); break;

                        case AMPropertyTrack.ValueType.Color:
                            tween = DOTween.To(new ColorPlugin(), () => (Color)propInfo.GetValue(comp, null), (x) => propInfo.SetValue(comp, x, null), endKey.color, getTime(frameRate)); break;

                        case AMPropertyTrack.ValueType.Rect:
                            tween = DOTween.To(new RectPlugin(), () => (Rect)propInfo.GetValue(comp, null), (x) => propInfo.SetValue(comp, x, null), endKey.rect, getTime(frameRate)); break;

                        case AMPropertyTrack.ValueType.Vector4:
                            tween = DOTween.To(new Vector4Plugin(), () => (Vector4)propInfo.GetValue(comp, null), (x) => propInfo.SetValue(comp, x, null), endKey.vect4, getTime(frameRate)); break;

                        case AMPropertyTrack.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 ((AMPropertyTrack.ValueType)valueType)
                            {
                            case AMPropertyTrack.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 AMPropertyTrack.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 AMPropertyTrack.ValueType.Double:
                                tween = DOTween.To(new DoublePlugin(), () => System.Convert.ToDouble(fieldInfo.GetValue(comp)), (x) => fieldInfo.SetValue(comp, x), endKey.val, getTime(frameRate)); break;

                            case AMPropertyTrack.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 AMPropertyTrack.ValueType.Vector2:
                                tween = DOTween.To(new Vector2Plugin(), () => (Vector2)fieldInfo.GetValue(comp), (x) => fieldInfo.SetValue(comp, x), endKey.vect2, getTime(frameRate)); break;

                            case AMPropertyTrack.ValueType.Vector3:
                                tween = DOTween.To(new Vector3Plugin(), () => (Vector3)fieldInfo.GetValue(comp), (x) => fieldInfo.SetValue(comp, x), endKey.vect3, getTime(frameRate)); break;

                            case AMPropertyTrack.ValueType.Color:
                                tween = DOTween.To(new ColorPlugin(), () => (Color)fieldInfo.GetValue(comp), (x) => fieldInfo.SetValue(comp, x), endKey.color, getTime(frameRate)); break;

                            case AMPropertyTrack.ValueType.Rect:
                                tween = DOTween.To(new RectPlugin(), () => (Rect)fieldInfo.GetValue(comp), (x) => fieldInfo.SetValue(comp, x), endKey.rect, getTime(frameRate)); break;

                            case AMPropertyTrack.ValueType.Vector4:
                                tween = DOTween.To(new Vector4Plugin(), () => (Vector4)fieldInfo.GetValue(comp), (x) => fieldInfo.SetValue(comp, x), endKey.vect4, getTime(frameRate)); break;

                            case AMPropertyTrack.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;
        }
예제 #20
0
        public override void build(AMSequence seq, AMTrack track, int index, UnityEngine.Object target)
        {
            AMMaterialTrack matTrack = track as AMMaterialTrack;

            AMMaterialTrack.ValueType 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;
            AMMaterialKey endKey     = index + 1 < keyCount ? track.keys[index + 1] as AMMaterialKey : null;
            float         frameCount = endKey != null ? endKey.frame - frame + 1 : 1f;

            switch (propType)
            {
            case AMMaterialTrack.ValueType.Float:
            case AMMaterialTrack.ValueType.Range:
                if (!canTween || keyCount == 1)     //allow one key
                {
                    var setTween = DOTween.To(new AMPlugValueSet <float>(), () => val, (x) => matInst.SetFloat(propId, x), val, frameCount / frameRate);
                    setTween.plugOptions.SetSequence(seq);
                    seq.Insert(this, setTween);
                }
                else
                {
                    if (targetsAreEqual(propType, endKey))
                    {
                        return;
                    }

                    tween = DOTween.To(new FloatPlugin(), () => matInst.GetFloat(propId), (x) => matInst.SetFloat(propId, x), endKey.val, getTime(frameRate));
                }
                break;

            case AMMaterialTrack.ValueType.Vector:
                if (!canTween || keyCount == 1)     //allow one key
                {
                    var setTween = DOTween.To(new AMPlugValueSet <Vector4>(), () => vector, (x) => matInst.SetVector(propId, x), vector, frameCount / frameRate);
                    setTween.plugOptions.SetSequence(seq);
                    seq.Insert(this, setTween);
                }
                else
                {
                    if (targetsAreEqual(propType, endKey))
                    {
                        return;
                    }

                    tween = DOTween.To(AMPluginFactory.CreateVector4(), () => matInst.GetVector(propId), (x) => matInst.SetVector(propId, x), endKey.vector, getTime(frameRate));
                }
                break;

            case AMMaterialTrack.ValueType.Color:
                if (!canTween || keyCount == 1)     //allow one key
                {
                    var val      = color;
                    var setTween = DOTween.To(new AMPlugValueSet <Color>(), () => val, (x) => matInst.SetColor(propId, x), val, frameCount / frameRate);
                    setTween.plugOptions.SetSequence(seq);
                    seq.Insert(this, setTween);
                }
                else
                {
                    if (targetsAreEqual(propType, endKey))
                    {
                        return;
                    }

                    tween = DOTween.To(AMPluginFactory.CreateColor(), () => matInst.GetColor(propId), (x) => matInst.SetColor(propId, x), endKey.color, getTime(frameRate));
                }
                break;

            case AMMaterialTrack.ValueType.TexOfs:
                if (!canTween || keyCount == 1)     //allow one key
                {
                    var val      = texOfs;
                    var setTween = DOTween.To(new AMPlugValueSet <Vector2>(), () => val, (x) => matInst.SetTextureOffset(prop, x), val, frameCount / frameRate);
                    setTween.plugOptions.SetSequence(seq);
                    seq.Insert(this, setTween);
                }
                else
                {
                    if (targetsAreEqual(propType, endKey))
                    {
                        return;
                    }

                    tween = DOTween.To(AMPluginFactory.CreateVector2(), () => matInst.GetTextureOffset(prop), (x) => matInst.SetTextureOffset(prop, x), endKey.texOfs, getTime(frameRate));
                }
                break;

            case AMMaterialTrack.ValueType.TexScale:
                if (!canTween || keyCount == 1)     //allow one key
                {
                    var val      = texScale;
                    var setTween = DOTween.To(new AMPlugValueSet <Vector2>(), () => val, (x) => matInst.SetTextureScale(prop, x), val, frameCount / frameRate);
                    setTween.plugOptions.SetSequence(seq);
                    seq.Insert(this, setTween);
                }
                else
                {
                    if (targetsAreEqual(propType, endKey))
                    {
                        return;
                    }

                    tween = DOTween.To(AMPluginFactory.CreateVector2(), () => matInst.GetTextureScale(prop), (x) => matInst.SetTextureScale(prop, x), endKey.texScale, getTime(frameRate));
                }
                break;

            case AMMaterialTrack.ValueType.TexEnv:
                var texEnvTween = DOTween.To(new AMPlugValueSet <Texture>(), () => texture, (x) => matInst.SetTexture(propId, x), texture, frameCount / frameRate);
                texEnvTween.plugOptions.SetSequence(seq);
                seq.Insert(this, texEnvTween);
                break;
            }

            if (tween != null)
            {
                if (hasCustomEase())
                {
                    tween.SetEase(easeCurve);
                }
                else
                {
                    tween.SetEase((Ease)easeType, amplitude, period);
                }

                seq.Insert(this, tween);
            }
        }
예제 #21
0
        public override void build(AMSequence seq, AMTrack track, int index, UnityEngine.Object obj)
        {
            int frameRate = seq.take.frameRate;

            //allow tracks with just one key
            if (track.keys.Count == 1)
            {
                interp = (int)Interpolation.None;
            }

            Transform trans = obj as Transform;

            AMTranslationTrack tTrack = track as AMTranslationTrack;
            bool  pixelSnap           = tTrack.pixelSnap;
            float ppu = tTrack.pixelPerUnit;

            if (!canTween)
            {
                //TODO: world position
                Vector3 pos = pixelSnap ? new Vector3(Mathf.Round(position.x * ppu) / ppu, Mathf.Round(position.y * ppu) / ppu, Mathf.Round(position.z * ppu) / ppu) : position;

                var tweener = DOTween.To(new AMPlugValueSet <Vector3>(), () => pos, (x) => trans.localPosition = x, pos, getTime(frameRate));
                tweener.plugOptions = new AMPlugValueSetOptions(seq.sequence);

                seq.Insert(this, tweener);
            }
            else
            {
                if (path.Length <= 1)
                {
                    return;
                }
                if (getNumberOfFrames(seq.take.frameRate) <= 0)
                {
                    return;
                }

                Tweener ret = null;

                bool isRelative = false;

                PathType pathType = path.Length == 2 ? PathType.Linear : PathType.CatmullRom;

                if (pixelSnap)
                {
                    ret = DOTween.To(new PlugVector3PathSnap(ppu), () => trans.localPosition, x => trans.localPosition = x, new Path(pathType, path, pathResolution), getTime(frameRate)).SetRelative(isRelative).SetOptions(isClosed);
                }
                else
                {
                    ret = trans.DOLocalPath(path, getTime(frameRate), pathType, PathMode.Full3D, pathResolution, null).SetRelative(isRelative).SetOptions(isClosed);
                }

                if (hasCustomEase())
                {
                    ret.SetEase(easeCurve);
                }
                else
                {
                    ret.SetEase((Ease)easeType, amplitude, period);
                }

                seq.Insert(this, ret);
            }
        }
예제 #22
0
        public override void build(AMSequence seq, AMTrack track, int index, UnityEngine.Object target)
        {
            int       frameRate = seq.take.frameRate;
            float     waitTime  = getWaitTime(frameRate, 0.0f);
            Animation anim      = (target as GameObject).GetComponent <Animation>();

            float duration = wrapMode == WrapMode.Once ? amClip.length : ((seq.take.getLastFrame() - frame) + 1) / (float)frameRate;

            if (crossfade)
            {
                if (index > 0)
                {
                    AMAnimationKey prevKey = track.keys[index - 1] as AMAnimationKey;

                    var prevAnimState = anim[prevKey.amClip.name];
                    var prevWrap      = prevKey.wrapMode;
                    var prevStartTime = prevKey.getWaitTime(frameRate, 0.0f);
                    var animState     = anim[amClip.name];

                    var tween = DOTween.To(new FloatPlugin(), () => 0f, (x) => {
                        if (x < crossfadeTime)
                        {
                            float weight = x / crossfadeTime;

                            prevAnimState.enabled  = true;
                            prevAnimState.wrapMode = prevWrap;
                            prevAnimState.weight   = 1.0f - weight;
                            prevAnimState.time     = (waitTime + x) - prevStartTime;

                            animState.enabled  = true;
                            animState.wrapMode = wrapMode;
                            animState.weight   = weight;
                            animState.time     = x;

                            anim.Sample();

                            prevAnimState.enabled = false;
                            animState.enabled     = false;
                        }
                        else
                        {
                            animState.enabled  = true;
                            animState.wrapMode = wrapMode;
                            animState.weight   = 1.0f;
                            animState.time     = x;

                            anim.Sample();

                            animState.enabled = false;
                        }
                    }, duration, duration);

                    seq.Insert(this, tween);
                }
                else
                {
                    var animState = anim[amClip.name];

                    var tween = DOTween.To(new FloatPlugin(), () => 0f, (x) => {
                        animState.enabled  = true;
                        animState.wrapMode = wrapMode;
                        animState.time     = x;

                        if (x < crossfadeTime)
                        {
                            animState.weight = x / crossfadeTime;
                        }
                        else
                        {
                            animState.weight = 1.0f;
                        }

                        anim.Sample();
                        animState.enabled = false;
                    }, duration, duration);

                    seq.Insert(this, tween);
                }
            }
            else
            {
                var animState = anim[amClip.name];

                var tween = DOTween.To(new FloatPlugin(), () => 0f, (x) => {
                    animState.enabled  = true;
                    animState.wrapMode = wrapMode;
                    animState.time     = x;
                    animState.weight   = 1.0f;
                    anim.Sample();
                    animState.enabled = false;
                }, duration, duration);

                seq.Insert(this, tween);
            }
        }
예제 #23
0
        public override void build(AMSequence seq, AMTrack 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 = (int)Interpolation.None;
            }

            if (!canTween)
            {
                switch ((track as AMRotationEulerTrack).axis)
                {
                case AMRotationEulerTrack.Axis.X:
                    float _x     = rotation.x;
                    var   tweenX = DOTween.To(new AMPlugValueSet <float>(), () => _x, (x) => { var a = target.localEulerAngles; a.x = x; target.localEulerAngles = a; }, _x, getTime(frameRate));
                    tweenX.plugOptions.SetSequence(seq);
                    seq.Insert(this, tweenX);
                    break;

                case AMRotationEulerTrack.Axis.Y:
                    float _y     = rotation.y;
                    var   tweenY = DOTween.To(new AMPlugValueSet <float>(), () => _y, (y) => { var a = target.localEulerAngles; a.y = y; target.localEulerAngles = a; }, _y, getTime(frameRate));
                    tweenY.plugOptions.SetSequence(seq);
                    seq.Insert(this, tweenY);
                    break;

                case AMRotationEulerTrack.Axis.Z:
                    float _z     = rotation.z;
                    var   tweenZ = DOTween.To(new AMPlugValueSet <float>(), () => _z, (z) => { var a = target.localEulerAngles; a.z = z; target.localEulerAngles = a; }, _z, getTime(frameRate));
                    tweenZ.plugOptions.SetSequence(seq);
                    seq.Insert(this, tweenZ);
                    break;

                default:
                    var tweenV = DOTween.To(new AMPlugValueSet <Vector3>(), () => rotation, (r) => { target.localEulerAngles = r; }, rotation, getTime(frameRate));
                    tweenV.plugOptions.SetSequence(seq);
                    seq.Insert(this, tweenV);
                    break;
                }
            }
            else if (endFrame == -1)
            {
                return;
            }
            else
            {
                Vector3 endRotation = (track.keys[index + 1] as AMRotationEulerKey).rotation;

                Tweener tween;

                switch ((track as AMRotationEulerTrack).axis)
                {
                case AMRotationEulerTrack.Axis.X:
                    tween = DOTween.To(new FloatPlugin(), () => target.localEulerAngles.x, (x) => { var a = target.localEulerAngles; a.x = x; target.localEulerAngles = a; }, endRotation.x, getTime(frameRate));
                    break;

                case AMRotationEulerTrack.Axis.Y:
                    tween = DOTween.To(new FloatPlugin(), () => target.localEulerAngles.y, (y) => { var a = target.localEulerAngles; a.y = y; target.localEulerAngles = a; }, endRotation.y, getTime(frameRate));
                    break;

                case AMRotationEulerTrack.Axis.Z:
                    tween = DOTween.To(new FloatPlugin(), () => target.localEulerAngles.z, (z) => { var a = target.localEulerAngles; a.z = z; target.localEulerAngles = a; }, endRotation.z, getTime(frameRate));
                    break;

                default:
                    tween = DOTween.To(AMPluginFactory.CreateVector3(), () => target.localEulerAngles, (x) => target.localEulerAngles = x, endRotation, getTime(frameRate));
                    break;
                }

                if (hasCustomEase())
                {
                    tween.SetEase(easeCurve);
                }
                else
                {
                    tween.SetEase((Ease)easeType, amplitude, period);
                }

                seq.Insert(this, tween);
            }
        }