예제 #1
0
 public void CopyTo(AMTrack track)
 {
     track.id = id;
     track.name = name;
     track._targetPath = _targetPath;
     DoCopy(track);
 }
예제 #2
0
        public WrapMode wrapMode; // animation wrap mode

        #endregion Fields

        #region Methods

        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;

            Holoville.HOTween.Plugins.Core.ABSTweenPlugin plug;

            if(crossfade) {
                if(index > 0) {
                    AMAnimationKey prevKey = track.keys[index - 1] as AMAnimationKey;
                    plug = new AMPlugAnimationCrossFade(anim, crossfadeTime, prevKey.amClip.name, prevKey.wrapMode, prevKey.getWaitTime(frameRate, 0.0f), amClip.name, wrapMode, waitTime);
                }
                else
                    plug = new AMPlugAnimation(anim, amClip.name, wrapMode, true, crossfadeTime);
            }
            else
                plug = new AMPlugAnimation(anim, amClip.name, wrapMode, false, 0.0f);

            seq.sequence.Insert(waitTime, HOTween.To(target, duration, new TweenParms().Prop("animation", plug)));

            //seq.Insert(new AMActionAnimation(this, seq.take.frameRate, (target as GameObject).animation));
            //seq.sequence.InsertCallback(getWaitTime(seq.take.frameRate, 0.0f), OnMethodCallbackParams, (target as GameObject).animation, (float)seq.take.frameRate);
        }
예제 #3
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;
            }
            if(cachedMethodInfo == null)
                cachedMethodInfo = comp.GetType().GetMethod(methodName, GetParamTypes());

            float waitTime = getWaitTime(seq.take.frameRate, 0.0f);

            if(useSendMessage) {
                if(parameters == null || parameters.Count <= 0)
                    seq.sequence.InsertCallback(waitTime, comp.gameObject, methodName, null, SendMessageOptions.DontRequireReceiver);
                else
                    seq.sequence.InsertCallback(waitTime, comp.gameObject, methodName, parameters[0].toObject(), SendMessageOptions.DontRequireReceiver);
            }
            else {
                seq.sequence.InsertCallback(waitTime, OnMethodCallbackParams, comp, (object)buildParams());
            }
        }
예제 #4
0
 public static void setValues(AMKey _key, AMTrack _track)
 {
     justSet = true;
     key = _key;
     track = _track;
     //aData = _aData;
     selectedIndex = key.easeType;
 }
예제 #5
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));
        }
예제 #6
0
	    public static void RecordUndoTrackAndKeys(AMTrack track, bool complete, string label) {
	        if(complete) {
	            Undo.RegisterCompleteObjectUndo(track, label);
	            Undo.RegisterCompleteObjectUndo(track.keys.ToArray(), label);
	        }
	        else {
	            Undo.RecordObject(track, label);
	            Undo.RecordObjects(track.keys.ToArray(), label);
	        }
	    }
예제 #7
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));
            }
        }
예제 #8
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))));
        }
예제 #9
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);
            }
        }
예제 #10
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)));
            }
        }
예제 #11
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)));
         }
     }
 }
예제 #12
0
파일: AMKey.cs 프로젝트: igrir/MateAnimator
 /// <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.");
 }
예제 #13
0
	    public static void SetDirtyKeys(AMTrack track) {
	        foreach(AMKey key in track.keys)
	            EditorUtility.SetDirty(key);
	    }
예제 #14
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;
            }
        }
예제 #15
0
 protected override void DoCopy(AMTrack track)
 {
     (track as AMAudioTrack).audioSource = audioSource;
 }
예제 #16
0
 protected override void DoCopy(AMTrack track)
 {
 }
예제 #17
0
 protected override void DoCopy(AMTrack track)
 {
     AMGOSetActiveTrack ntrack = track as AMGOSetActiveTrack;
     ntrack.obj = obj;
     ntrack.startActive = startActive;
 }
예제 #18
0
 private void addTrack(int groupId, AMTrack track)
 {
     trackValues.Add(track);
     addToGroup(track.id, groupId);
     sortTracks();
 }
예제 #19
0
        protected override void DoCopy(AMTrack track)
        {
            AMMaterialTrack ntrack = track as AMMaterialTrack;

            ntrack.obj = obj;
            ntrack._matOverride = _matOverride;
            ntrack._matInd = _matInd;
            ntrack._property = _property;
            ntrack._propertyType = _propertyType;
        }
예제 #20
0
 // returns true if autokey successful
 public bool autoKey(AMITarget itarget, AMTrack.OnAddKey addCall, Transform obj, int frame)
 {
     if(!obj) return false;
     bool didKey = false;
     foreach(AMTrack track in trackValues) {
         // for each track, if rotation or translation then autokey
         if(track is AMTranslationTrack) {
             if((track as AMTranslationTrack).autoKey(itarget, addCall, obj, frame, frameRate)) {
                 if(!didKey) didKey = true;
                 //track.updateCache();
             }
         }
         else if(track is AMRotationTrack) {
             if((track as AMRotationTrack).autoKey(itarget, addCall, obj, frame, frameRate)) {
                 if(!didKey) didKey = true;
             }
         }
         else if(track is AMRotationEulerTrack) {
             if((track as AMRotationEulerTrack).autoKey(itarget, addCall, obj, frame, frameRate)) {
                 if(!didKey) didKey = true;
             }
         }
     }
     return didKey;
 }
예제 #21
0
 // add translation track
 public void addTrack(int groupId, AMITarget target, Transform obj, AMTrack a)
 {
     a.setName(getTrackCount());
     a.id = getUniqueTrackID();
     a.enabled = false;
     a.SetTarget(target, obj);
     addTrack(groupId, a);
     if(a is AMCameraSwitcherTrack) mCameraSwitcher = a as AMCameraSwitcherTrack;
 }
예제 #22
0
        public override void build(AMSequence seq, AMTrack track, int index, UnityEngine.Object target)
        {
            float sTime = getWaitTime(seq.take.frameRate, 0.0f);

            seq.sequence.InsertCallback(sTime, OnMethodCallbackParams, target as AudioSource);
        }
예제 #23
0
 void AMITarget.MaintainTargetCache(AMTrack track)
 {
     if((this as AMITarget).isMeta && mCache.ContainsKey(track.targetPath)) {
         UnityEngine.Object obj = track.GetTarget(this);
         if(obj) {
             string objPath = AMUtil.GetPath(transform, obj);
             if(objPath != track.targetPath) {
                 mCache.Remove(track.targetPath);
             }
         }
     }
 }
예제 #24
0
 protected override void DoCopy(AMTrack track)
 {
     AMRotationTrack ntrack = track as AMRotationTrack;
     ntrack._obj = _obj;
     ntrack.cachedInitialRotation = cachedInitialRotation;
 }
예제 #25
0
 protected override void DoCopy(AMTrack track)
 {
     (track as AMEventTrack).obj = obj;
 }
예제 #26
0
        private void deleteTrack(AMTrack track, bool deleteFromGroup, ref List<MonoBehaviour> modifiedItems)
        {
            int id = track.id;
            int index = getTrackIndex(id);
            if(track && modifiedItems != null) {
                foreach(AMKey key in track.keys)
                    modifiedItems.Add(key);

                modifiedItems.Add(track);
            }
            if(mCameraSwitcher == track) mCameraSwitcher = null;
            trackValues.RemoveAt(index);
            if(deleteFromGroup) deleteTrackFromGroups(id);
            sortTracks();
        }
예제 #27
0
        public void deleteTrack(AMTrack track, bool deleteFromGroup = true)
        {
            int id = track.id;
            int index = getTrackIndex(id);
            if(track) {
                if(mCameraSwitcher == track) mCameraSwitcher = null;
                track.destroy();
            }

            trackValues.RemoveAt(index);
            if(deleteFromGroup) deleteTrackFromGroups(id);
            sortTracks();
        }
예제 #28
0
 public override void build(AMSequence seq, AMTrack track, int index, UnityEngine.Object obj)
 {
     seq.sequence.InsertCallback(getWaitTime(seq.take.frameRate, 0.0f), seq.triggerCallback,
         this,
         new AMTriggerData() { valueString=this.valueString, valueInt=this.valueInt, valueFloat=this.valueFloat });
 }
예제 #29
0
 protected override void DoCopy(AMTrack track)
 {
     (track as AMAnimationTrack).obj = obj;
 }
예제 #30
0
        static int TrackCompare(AMTrack t1, AMTrack t2)
        {
            if(t1 == t2)
                return 0;
            else if(t1 == null)
                return 1;
            else if(t2 == null)
                return -1;

            return t1.order - t2.order;
        }