示例#1
0
        private static FAnimationTrackCache GetAnimationPreview(FAnimationTrack animTrack, bool createIfDoesntExist)
        {
            Dictionary <int, FAnimationTrackCache> sequencePreviews = null;

            if (!_animPreviews.TryGetValue(animTrack.Sequence.GetInstanceID(), out sequencePreviews))
            {
                if (!createIfDoesntExist)
                {
                    return(null);
                }
                sequencePreviews = new Dictionary <int, FAnimationTrackCache>();
                _animPreviews.Add(animTrack.Sequence.GetInstanceID(), sequencePreviews);
            }

            FAnimationTrackCache preview = null;

            if (!sequencePreviews.TryGetValue(animTrack.Owner.GetInstanceID(), out preview))
            {
                if (!createIfDoesntExist)
                {
                    return(null);
                }
                preview = new FAnimationTrackCache(animTrack);
                sequencePreviews.Add(animTrack.Owner.GetInstanceID(), preview);
            }

            return(preview);
        }
示例#2
0
        private static void DeleteAnimationPreview(FAnimationTrack animTrack)
        {
            Dictionary <int, FAnimationTrackCache> sequencePreviews = null;

            if (_animPreviews.TryGetValue(animTrack.Sequence.GetInstanceID(), out sequencePreviews))
            {
                sequencePreviews[animTrack.Owner.GetInstanceID()].Clear();
                sequencePreviews.Remove(animTrack.Owner.GetInstanceID());
            }
        }
示例#3
0
        private static void DeleteAnimationPreview(FAnimationTrack animTrack)
        {
            Dictionary <int, FAnimationTrackCache> sequencePreviews = null;
            int seqId = animTrack.Sequence.GetInstanceID();

            if (_animPreviews.TryGetValue(seqId, out sequencePreviews))
            {
                int trackID = animTrack.Owner.GetInstanceID();
                sequencePreviews[trackID].Clear();
                sequencePreviews.Remove(trackID);
            }
        }
示例#4
0
        protected override bool ClearInternal()
        {
#if FLUX_DEBUG
            Debug.LogWarning("Destroying Sequence Preview");
#endif

            FSequence sequence = Track.Owner.GetComponent <FSequence>();

            foreach (FContainer container in sequence.Containers)
            {
                foreach (FTimeline timeline in container.Timelines)
                {
                    foreach (FTrack track in timeline.Tracks)
                    {
                        if (track.CanTogglePreview)
                        {
                            track.CanPreview = false;
                        }
                    }
                }
            }

            foreach (FContainer container in sequence.Containers)
            {
                foreach (FTimeline timeline in container.Timelines)
                {
                    foreach (FTrack track in timeline.Tracks)
                    {
                        if (track.HasCache)
                        {
                            track.ClearCache();
                        }
                    }
                }
            }

            FAnimationTrack.DeleteAnimationPreviews(sequence);

            return(true);
        }
示例#5
0
        protected override void OnTrigger(float timeSinceTrigger)
        {
            _animator  = Owner.GetComponent <Animator>();
            _animTrack = (FAnimationTrack)_track;

            if (_animator.runtimeAnimatorController != _animTrack.AnimatorController)
            {
                _animator.runtimeAnimatorController = _animTrack.AnimatorController;
            }

            _animator.enabled = _animationClip != null;

            int id = GetId();

#if UNITY_EDITOR
            if (_animator.enabled && (!_track.HasCache || Application.isPlaying))
#else
            if (_animator.enabled)
#endif
            {
                //				Debug.Log( "Turning on " + _animTrack.LayerName );
                _animator.SetLayerWeight(_animTrack.LayerId, 1);
                if (id == 0 || _track.Events[id - 1].End < Start)
                {
                    _animator.Play(_stateHash, _animTrack.LayerId, (_startOffset * Sequence.InverseFrameRate) / _animationClip.length);
                }

                if (timeSinceTrigger > 0)
                {
                    // - 0.001f because if you pass the length of the animation
                    // it seems that it will go over it and miss the condition
                    _animator.Update(timeSinceTrigger - 0.001f);
                }
                else
                {
                    _animator.Update(0f);
                }
            }
        }
        protected override void OnTrigger(int framesSinceTrigger, float timeSinceTrigger)
        {
            _animator = Owner.GetComponent <Animator>();

            FAnimationTrack animationTrack = (FAnimationTrack)_track;

            if (_animator.runtimeAnimatorController != animationTrack.GetAnimatorController())
            {
                _animator.runtimeAnimatorController = animationTrack.GetAnimatorController();
            }

            _animator.enabled = _animationClip != null;

            int id = GetId();

            if (_animator.enabled)
            {
                if (id == 0)
                {
                    _animator.Play(_stateHash, 0, _startOffset * Sequence.InverseFrameRate);
                }
                else if (_track.GetEvents()[id - 1].End < Start)
                {
                    _animator.SetTrigger(ADVANCE_TRIGGER);
                }
                else
                {
                    _animator.ResetTrigger(ADVANCE_TRIGGER);
                }

                if (framesSinceTrigger > 0)
                {
                    // - 0.001f because if you pass the length of the animation
                    // it seems that it will go over it and miss the condition
                    _animator.Update(timeSinceTrigger - 0.001f);
                }
            }
        }
示例#7
0
        protected override bool ClearInternal()
        {
#if FLUX_DEBUG
            Debug.LogWarning("Destroying Sequence Preview");
#endif

            FSequence sequence = ((FSequenceTrack)Track).OwnerSequence;

            foreach (FContainer container in sequence.Containers)
            {
                foreach (FTrack track in container.Tracks)
                {
                    if (track.HasCache)
                    {
                        track.ClearCache();
                    }
                }
            }
            FAnimationTrack.DeleteAnimationPreviews(sequence);


            return(true);
        }
示例#8
0
 private static FAnimationTrackCache GetAnimationPreview(FAnimationTrack animTrack)
 {
     return(GetAnimationPreview(animTrack, true));
 }
 protected override void OnInit()
 {
     base.OnInit();
     _animTrack = (FAnimationTrack)_track;
 }