Пример #1
0
 public void Insert(AMKey key, Tweener tween)
 {
     mSequence.Insert(key.getWaitTime(mTake.frameRate, 0.0f), tween);
 }
Пример #2
0
 public void Trigger(AMKey key, AMTriggerData data)
 {
     mTarget.SequenceTrigger(this, key, data);
 }
Пример #3
0
 public int getKeyIndex(AMKey key)
 {
     return(keys.IndexOf(key));
 }
Пример #4
0
        /// <summary>
        /// This will only duplicate the tracks and groups, includeKeys=true to also duplicate keys
        /// </summary>
        /// <param name="take"></param>
        public void DuplicateTake(AMTakeData dupTake, bool includeKeys, bool addCompUndo)
        {
            AMTakeData a = new AMTakeData();

            a.name = dupTake.name;
            MakeTakeNameUnique(a);
            a.numLoop         = dupTake.numLoop;
            a.loopMode        = dupTake.loopMode;
            a.frameRate       = dupTake.frameRate;
            a.endFramePadding = dupTake.endFramePadding;
            //a.lsTracks = new List<AMTrack>();
            //a.dictTracks = new Dictionary<int,AMTrack>();

            if (dupTake.rootGroup != null)
            {
                a.rootGroup = dupTake.rootGroup.duplicate();
            }
            else
            {
                a.initGroups();
            }

            a.group_count = dupTake.group_count;

            if (dupTake.groupValues != null)
            {
                a.groupValues = new List <AMGroup>();
                foreach (AMGroup grp in dupTake.groupValues)
                {
                    a.groupValues.Add(grp.duplicate());
                }
            }

            a.track_count = dupTake.track_count;

            if (dupTake.trackValues != null)
            {
                a.trackValues = new List <AMTrack>();
                foreach (AMTrack track in dupTake.trackValues)
                {
                    GameObject holderGO = (this as AMITarget).holder.gameObject;
                    AMTrack    dupTrack = (addCompUndo ? UnityEditor.Undo.AddComponent(holderGO, track.GetType()) : holderGO.AddComponent(track.GetType())) as AMTrack;
                    dupTrack.enabled = false;
                    track.CopyTo(dupTrack);
                    a.trackValues.Add(dupTrack);

                    dupTrack.maintainTrack(mDataTarget);

                    Object tgtObj = dupTrack.GetTarget(mDataTarget);

                    //if there's no target, then we can't add the keys for events and properties
                    if (includeKeys && !(tgtObj == null && (dupTrack is AMPropertyTrack || dupTrack is AMEventTrack)))
                    {
                        foreach (AMKey key in track.keys)
                        {
                            AMKey dupKey = (addCompUndo ? UnityEditor.Undo.AddComponent(holderGO, key.GetType()) : holderGO.AddComponent(key.GetType())) as AMKey;
                            if (dupKey)
                            {
                                key.CopyTo(dupKey);
                                dupKey.enabled = false;
                                dupKey.maintainKey(mDataTarget, tgtObj);
                                dupTrack.keys.Add(dupKey);
                            }
                        }

                        dupTrack.updateCache(mDataTarget);
                    }
                }
            }

            takes.Add(a);
        }
Пример #5
0
 public virtual void CopyTo(AMKey key)
 {
     Debug.LogError("Animator: No override for CopyTo()");
 }
Пример #6
0
        public void Build(bool autoKill, UpdateType updateType, bool updateTimeIndependent)
        {
            if (mSequence != null)
            {
                mSequence.Kill();
            }

            //create sequence
            mSequence = DOTween.Sequence();
            mSequence.SetUpdate(updateType, updateTimeIndependent);
            mSequence.SetAutoKill(mIsAutoKill = autoKill);

            if (mTake.numLoop < 0 && mTake.loopBackToFrame > 0)
            {
                if (mTake.loopMode == LoopType.Yoyo)
                {
                    mSequence.SetLoops(2, mTake.loopMode);
                }
                else
                {
                    mSequence.SetLoops(1, mTake.loopMode); //allow sequence to end so we can loop back to specific frame
                }
            }
            else
            {
                mSequence.SetLoops(mTake.numLoop, mTake.loopMode);
            }

            mSequence.OnComplete(OnSequenceComplete);

            mTake.maintainCaches(mTarget);

            float minWaitTime = float.MaxValue;

            foreach (AMTrack track in mTake.trackValues)
            {
                Object tgt = null;
                if ((tgt = track.GetTarget(mTarget)) != null)
                {
                    track.buildSequenceStart(this);

                    int keyMax = track.keys.Count;
                    if (keyMax > 0)
                    {
                        for (int keyInd = 0; keyInd < keyMax; keyInd++)
                        {
                            AMKey key = track.keys[keyInd];
                            key.build(this, track, keyInd, tgt);
                        }

                        float waitTime = track.keys[0].getWaitTime(mTake.frameRate, 0.0f);
                        if (waitTime < minWaitTime)
                        {
                            minWaitTime = waitTime;
                        }
                    }
                }
            }

            //prepend delay at the beginning
            if (minWaitTime > 0.0f)
            {
                mSequence.PrependInterval(minWaitTime);
            }

            //append delay at the end
            if ((mTake.numLoop >= 0 || mTake.loopBackToFrame <= 0) && mTake.endFramePadding > 0)
            {
                mSequence.AppendInterval(mTake.endFramePadding / (float)mTake.frameRate);
            }
        }