Ejemplo n.º 1
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:
                        seq.Insert(new AMActionTransLocalRotEulerX(this, frameRate, target, rotation.x));
                        break;
                    case AMRotationEulerTrack.Axis.Y:
                        seq.Insert(new AMActionTransLocalRotEulerY(this, frameRate, target, rotation.y));
                        break;
                    case AMRotationEulerTrack.Axis.Z:
                        seq.Insert(new AMActionTransLocalRotEulerZ(this, frameRate, target, rotation.z));
                        break;
                    default:
                        seq.Insert(new AMActionTransLocalRotEuler(this, frameRate, target, rotation));
                        break;
                }
            }
            else if(endFrame == -1) return;
            else {
                Vector3 endRotation = (track.keys[index + 1] as AMRotationEulerKey).rotation;

                TweenParms tParms = new TweenParms();

                switch((track as AMRotationEulerTrack).axis) {
                    case AMRotationEulerTrack.Axis.X:
                        tParms = tParms.Prop("rotation", new AMPlugToTransformLocalEulerX(target, endRotation.x));
                        break;
                    case AMRotationEulerTrack.Axis.Y:
                        tParms = tParms.Prop("rotation", new AMPlugToTransformLocalEulerY(target, endRotation.y));
                        break;
                    case AMRotationEulerTrack.Axis.Z:
                        tParms = tParms.Prop("rotation", new AMPlugToTransformLocalEulerZ(target, endRotation.z));
                        break;
                    default:
                        tParms = tParms.Prop("rotation", new AMPlugToTransformLocalEuler(target, endRotation));
                        break;
                }

                if(hasCustomEase())
                    tParms = tParms.Ease(easeCurve);
                else
                    tParms = tParms.Ease((EaseType)easeType, amplitude, period);

                seq.Insert(this, HOTween.To(this, getTime(frameRate), tParms));
            }
        }
Ejemplo n.º 2
0
        public override void buildSequenceStart(AMSequence seq)
        {
            GameObject go = GetTarget(seq.target) as GameObject;

            //need to add activate game object on start to 'reset' properly during reverse
            if(keys.Count > 0 && keys[0].frame > 0) {
                seq.Insert(new AMActionGOActive(0.0f, keys[0].getWaitTime(seq.take.frameRate, 0.0f), go, startActive));
            }
        }
Ejemplo n.º 3
0
        public override void build(AMSequence seq, AMTrack track, int index, UnityEngine.Object target)
        {
            GameObject go = target as GameObject;

            if(go == null) return;

            //active won't really be set, it's just a filler along with ease
            seq.Insert(new AMActionGOActive(this, seq.take.frameRate, go, setActive));
        }
Ejemplo n.º 4
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);

            //use 'this' with property 'type' as a placeholder since AMPlugCameraSwitcher does not require any property
            seq.Insert(this, HOTween.To(this, getTime(seq.take.frameRate), new TweenParms().Prop("type",
                new AMPlugCameraSwitcher(this, seq.take.frameRate, seq.target, allCameras))));
        }
Ejemplo n.º 5
0
 public override void build(AMSequence seq, AMTrack track, int index, UnityEngine.Object obj)
 {
     if(!obj) return;
     int frameRate = seq.take.frameRate;
     if(!canTween) {
         seq.Insert(this, HOTween.To(obj, getTime(frameRate), new TweenParms().Prop("rotation", new AMPlugOrientation(GetTarget(seq.target), null))));
     }
     if(endFrame == -1) return;
     Transform tgt = GetTarget(seq.target), tgte = (track.keys[index+1] as AMOrientationKey).GetTarget(seq.target);
     if(tgt == tgte) {
         seq.Insert(this, HOTween.To(obj, getTime(frameRate), new TweenParms().Prop("rotation", new AMPlugOrientation(tgt, null))));
     }
     else {
         if(hasCustomEase()) {
             seq.Insert(this, HOTween.To(obj, getTime(frameRate), new TweenParms().Prop("rotation", new AMPlugOrientation(tgt, tgte)).Ease(easeCurve)));
         }
         else {
             seq.Insert(this, HOTween.To(obj, getTime(frameRate), new TweenParms().Prop("rotation", new AMPlugOrientation(tgt, tgte)).Ease((EaseType)easeType, amplitude, period)));
         }
     }
 }
Ejemplo n.º 6
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;

            if(!canTween) {
                seq.Insert(new AMActionTransLocalRot(this, frameRate, obj as Transform, rotation));
            }
            else if(endFrame == -1) return;
            else {
                Quaternion endRotation = (track.keys[index + 1] as AMRotationKey).rotation;

                if(hasCustomEase())
                    seq.Insert(this, HOTween.To(obj, getTime(frameRate), new TweenParms().Prop("localRotation", new AMPlugQuaternionSlerp(endRotation)).Ease(easeCurve)));
                else
                    seq.Insert(this, HOTween.To(obj, getTime(frameRate), new TweenParms().Prop("localRotation", new AMPlugQuaternionSlerp(endRotation)).Ease((EaseType)easeType, amplitude, period)));
            }
        }
Ejemplo n.º 7
0
        public override void build(AMSequence seq, AMTrack track, int index, UnityEngine.Object target)
        {
            AMMaterialTrack matTrack = track as AMMaterialTrack;

            Material matInst = matTrack.materialInstance;
            string prop = matTrack.property;
            AMMaterialTrack.ValueType propType = matTrack.propertyType;

            int frameRate = seq.take.frameRate;

            switch(propType) {
                case AMMaterialTrack.ValueType.Float:
                case AMMaterialTrack.ValueType.Range:
                    if(!canTween || matTrack.keys.Count == 1) //allow one key
                        seq.Insert(new AMActionMaterialFloatSet(this, frameRate, matInst, prop, val));
                    else {
                        AMMaterialKey endKey = track.keys[index + 1] as AMMaterialKey;
                        if(targetsAreEqual(propType, endKey)) return;

                        if(hasCustomEase())
                            seq.Insert(this, HOTween.To(this, getTime(frameRate), new TweenParms().Prop(bsField, new AMPlugMaterialFloat(matInst, prop, endKey.val)).Ease(easeCurve)));
                        else
                            seq.Insert(this, HOTween.To(this, getTime(frameRate), new TweenParms().Prop(bsField, new AMPlugMaterialFloat(matInst, prop, endKey.val)).Ease((EaseType)easeType, amplitude, period)));
                    }
                    break;
                case AMMaterialTrack.ValueType.Vector:
                    if(!canTween || matTrack.keys.Count == 1) //allow one key
                        seq.Insert(new AMActionMaterialVectorSet(this, frameRate, matInst, prop, vector));
                    else {
                        AMMaterialKey endKey = track.keys[index + 1] as AMMaterialKey;
                        if(targetsAreEqual(propType, endKey)) return;

                        if(hasCustomEase())
                            seq.Insert(this, HOTween.To(this, getTime(frameRate), new TweenParms().Prop(bsField, new AMPlugMaterialVector4(matInst, prop, endKey.vector)).Ease(easeCurve)));
                        else
                            seq.Insert(this, HOTween.To(this, getTime(frameRate), new TweenParms().Prop(bsField, new AMPlugMaterialVector4(matInst, prop, endKey.vector)).Ease((EaseType)easeType, amplitude, period)));
                    }
                    break;
                case AMMaterialTrack.ValueType.Color:
                    if(!canTween || matTrack.keys.Count == 1) //allow one key
                        seq.Insert(new AMActionMaterialColorSet(this, frameRate, matInst, prop, color));
                    else {
                        AMMaterialKey endKey = track.keys[index + 1] as AMMaterialKey;
                        if(targetsAreEqual(propType, endKey)) return;

                        if(hasCustomEase())
                            seq.Insert(this, HOTween.To(this, getTime(frameRate), new TweenParms().Prop(bsField, new AMPlugMaterialColor(matInst, prop, endKey.color)).Ease(easeCurve)));
                        else
                            seq.Insert(this, HOTween.To(this, getTime(frameRate), new TweenParms().Prop(bsField, new AMPlugMaterialColor(matInst, prop, endKey.color)).Ease((EaseType)easeType, amplitude, period)));
                    }
                    break;
                case AMMaterialTrack.ValueType.TexOfs:
                    if(!canTween || matTrack.keys.Count == 1) //allow one key
                        seq.Insert(new AMActionMaterialTexOfsSet(this, frameRate, matInst, prop, texOfs));
                    else {
                        AMMaterialKey endKey = track.keys[index + 1] as AMMaterialKey;
                        if(targetsAreEqual(propType, endKey)) return;

                        if(hasCustomEase())
                            seq.Insert(this, HOTween.To(this, getTime(frameRate), new TweenParms().Prop(bsField, new AMPlugMaterialTexOfs(matInst, prop, endKey.texOfs)).Ease(easeCurve)));
                        else
                            seq.Insert(this, HOTween.To(this, getTime(frameRate), new TweenParms().Prop(bsField, new AMPlugMaterialTexOfs(matInst, prop, endKey.texOfs)).Ease((EaseType)easeType, amplitude, period)));
                    }
                    break;
                case AMMaterialTrack.ValueType.TexScale:
                    if(!canTween || matTrack.keys.Count == 1) //allow one key
                        seq.Insert(new AMActionMaterialTexScaleSet(this, frameRate, matInst, prop, texScale));
                    else {
                        AMMaterialKey endKey = track.keys[index + 1] as AMMaterialKey;
                        if(targetsAreEqual(propType, endKey)) return;

                        if(hasCustomEase())
                            seq.Insert(this, HOTween.To(this, getTime(frameRate), new TweenParms().Prop(bsField, new AMPlugMaterialTexScale(matInst, prop, endKey.texScale)).Ease(easeCurve)));
                        else
                            seq.Insert(this, HOTween.To(this, getTime(frameRate), new TweenParms().Prop(bsField, new AMPlugMaterialTexScale(matInst, prop, endKey.texScale)).Ease((EaseType)easeType, amplitude, period)));
                    }
                    break;
                case AMMaterialTrack.ValueType.TexEnv:
                    seq.Insert(new AMActionMaterialTexSet(this, frameRate, matInst, prop, texture));
                    break;
            }
        }
Ejemplo n.º 8
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;

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

            if(!canTween) {
                //TODO: world position
                seq.Insert(new AMActionTransLocalPos(this, frameRate, obj as Transform, pixelSnap ? new Vector3(Mathf.Round(position.x*ppu)/ppu, Mathf.Round(position.y*ppu)/ppu, Mathf.Round(position.z*ppu)/ppu) : position));
            }
            else {
                if(path.Length <= 1) return;
                if(getNumberOfFrames(seq.take.frameRate) <= 0) return;

                object tweenTarget = obj;
                string tweenProp = "localPosition";

                Tweener ret = null;

                bool isRelative = false;

                if(hasCustomEase()) {
                    if(path.Length == 2)
                        ret = HOTween.To(tweenTarget, getTime(frameRate), new TweenParms().Prop(tweenProp, pixelSnap ? new PlugVector3PathSnap(path, ppu, isRelative, PathType.Linear) : new PlugVector3Path(path, isRelative, PathType.Linear)).Ease(easeCurve));
                    else {
                        PlugVector3Path p = pixelSnap ? new PlugVector3PathSnap(path, ppu, isRelative) : new PlugVector3Path(path, isRelative);
                        p.ClosePath(isClosed);
                        ret = HOTween.To(tweenTarget, getTime(frameRate), new TweenParms().Prop(tweenProp, p).Ease(easeCurve));
                    }
                }
                else {
                    if(path.Length == 2)
                        ret = HOTween.To(tweenTarget, getTime(frameRate), new TweenParms().Prop(tweenProp, pixelSnap ? new PlugVector3PathSnap(path, ppu, isRelative, PathType.Linear) : new PlugVector3Path(path, isRelative, PathType.Linear)).Ease((EaseType)easeType, amplitude, period));
                    else {
                        PlugVector3Path p = pixelSnap ? new PlugVector3PathSnap(path, ppu, isRelative) : new PlugVector3Path(path, isRelative);
                        p.ClosePath(isClosed);
                        ret = HOTween.To(tweenTarget, getTime(frameRate), new TweenParms().Prop(tweenProp, p).Ease((EaseType)easeType, amplitude, period));
                    }
                }

                seq.Insert(this, ret);
            }
        }
Ejemplo n.º 9
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)) {
                if(propTrack.canTween) {
                    //allow tracks with just one key
                    if(track.keys.Count == 1)
                        interp = (int)Interpolation.None;

                    if(!canTween) {
                        object obj = null;

                        switch((AMPropertyTrack.ValueType)valueType) {
                            case AMPropertyTrack.ValueType.Integer:
                                obj = System.Convert.ToInt32(val); break;
                            case AMPropertyTrack.ValueType.Float:
                                obj = System.Convert.ToSingle(val); break;
                            case AMPropertyTrack.ValueType.Double:
                                obj = val; break;
                            case AMPropertyTrack.ValueType.Long:
                                obj = System.Convert.ToInt64(val); break;
                            case AMPropertyTrack.ValueType.Vector2:
                                obj = vect2; break;
                            case AMPropertyTrack.ValueType.Vector3:
                                obj = vect3; break;
                            case AMPropertyTrack.ValueType.Color:
                                obj = color; break;
                            case AMPropertyTrack.ValueType.Rect:
                                obj = rect; break;
                            case AMPropertyTrack.ValueType.Vector4:
                                obj = vect4; break;
                            case AMPropertyTrack.ValueType.Quaternion:
                                obj = quat; break;
                        }

                        if(obj != null)
                            seq.Insert(GenerateActionData(propTrack, frameRate, comp, obj));
                    }
                    else {
                        //grab end frame
                        AMPropertyKey endKey = track.keys[index + 1] as AMPropertyKey;

                        if(targetsAreEqual(valueType, endKey)) return;

                        if(hasCustomEase()) {
                            switch((AMPropertyTrack.ValueType)valueType) {
                                case AMPropertyTrack.ValueType.Integer:
                                    seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, System.Convert.ToInt32(endKey.val)).Ease(easeCurve))); break;
                                case AMPropertyTrack.ValueType.Float:
                                    seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, System.Convert.ToSingle(endKey.val)).Ease(easeCurve))); break;
                                case AMPropertyTrack.ValueType.Double:
                                    seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, new AMPlugDouble(endKey.val)).Ease(easeCurve))); break;
                                case AMPropertyTrack.ValueType.Long:
                                    seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, new AMPlugLong(System.Convert.ToInt64(endKey.val))).Ease(easeCurve))); break;
                                case AMPropertyTrack.ValueType.Vector2:
                                    seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, endKey.vect2).Ease(easeCurve))); break;
                                case AMPropertyTrack.ValueType.Vector3:
                                    seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, endKey.vect3).Ease(easeCurve))); break;
                                case AMPropertyTrack.ValueType.Color:
                                    seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, endKey.color).Ease(easeCurve))); break;
                                case AMPropertyTrack.ValueType.Rect:
                                    seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, endKey.rect).Ease(easeCurve))); break;
                                case AMPropertyTrack.ValueType.Vector4:
                                    seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, endKey.vect4).Ease(easeCurve))); break;
                                case AMPropertyTrack.ValueType.Quaternion:
                                    seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, new AMPlugQuaternionSlerp(endKey.quat)).Ease(easeCurve))); break;
                            }
                        }
                        else {
                            switch((AMPropertyTrack.ValueType)valueType) {
                                case AMPropertyTrack.ValueType.Integer:
                                    seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, System.Convert.ToInt32(endKey.val)).Ease((EaseType)easeType, amplitude, period))); break;
                                case AMPropertyTrack.ValueType.Float:
                                    seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, System.Convert.ToSingle(endKey.val)).Ease((EaseType)easeType, amplitude, period))); break;
                                case AMPropertyTrack.ValueType.Double:
                                    seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, new AMPlugDouble(endKey.val)).Ease((EaseType)easeType, amplitude, period))); break;
                                case AMPropertyTrack.ValueType.Long:
                                    seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, new AMPlugLong(System.Convert.ToInt64(endKey.val))).Ease((EaseType)easeType, amplitude, period))); break;
                                case AMPropertyTrack.ValueType.Vector2:
                                    seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, endKey.vect2).Ease((EaseType)easeType, amplitude, period))); break;
                                case AMPropertyTrack.ValueType.Vector3:
                                    seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, endKey.vect3).Ease((EaseType)easeType, amplitude, period))); break;
                                case AMPropertyTrack.ValueType.Color:
                                    seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, endKey.color).Ease((EaseType)easeType, amplitude, period))); break;
                                case AMPropertyTrack.ValueType.Rect:
                                    seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, endKey.rect).Ease((EaseType)easeType, amplitude, period))); break;
                                case AMPropertyTrack.ValueType.Vector4:
                                    seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, endKey.vect4).Ease((EaseType)easeType, amplitude, period))); break;
                                case AMPropertyTrack.ValueType.Quaternion:
                                    seq.Insert(this, HOTween.To(comp, getTime(frameRate), new TweenParms().Prop(varName, new AMPlugQuaternionSlerp(endKey.quat)).Ease((EaseType)easeType, amplitude, period))); break;
                            }
                        }
                    }
                }
                else {
                    if(endFrame == -1) endFrame = frame + 1;

                    if(valueType == (int)AMPropertyTrack.ValueType.Bool) {
                        seq.Insert(GenerateActionData(propTrack, frameRate, comp, val > 0.0f));
                    }
                    else if(valueType == (int)AMPropertyTrack.ValueType.String) {
                        seq.Insert(GenerateActionData(propTrack, frameRate, comp, valString));
                    }
                    else if(valueType == (int)AMPropertyTrack.ValueType.Sprite) {
                        seq.Insert(new AMActionSpriteSet(this, frameRate, comp as SpriteRenderer, valObj as Sprite));
                    }
                    else if(valueType == (int)AMPropertyTrack.ValueType.Enum) {
                        System.Type infType = propTrack.GetCachedInfoType(seq.target);
                        object enumVal = infType != null ? System.Enum.ToObject(infType, (int)val) : null;
                        if(enumVal != null) {
                            seq.Insert(GenerateActionData(propTrack, frameRate, comp, enumVal));
                        }
                        else {
                            Debug.LogError("Invalid enum value.");
                        }
                    }
                }
            }
            else
                Debug.LogError("Animator: No FieldInfo or PropertyInfo set.");

            return;
        }