Exemplo n.º 1
0
        Playable CreateInfiniteTrackPlayable(PlayableGraph graph, GameObject go, IntervalTree <RuntimeElement> tree, AppliedOffsetMode mode)
        {
            if (m_InfiniteClip == null)
            {
                return(Playable.Null);
            }

            var mixer = AnimationMixerPlayable.Create(graph, 1);

            // In infinite mode, we always force the loop mode of the clip off because the clip keys are offset in infinite mode
            //  which causes loop to behave different.
            // The inline curve editor never shows loops in infinite mode.
            var playable = AnimationPlayableAsset.CreatePlayable(graph, m_InfiniteClip, m_InfiniteClipOffsetPosition, m_InfiniteClipOffsetEulerAngles, false, mode, infiniteClipApplyFootIK, AnimationPlayableAsset.LoopMode.Off);

            if (playable.IsValid())
            {
                tree.Add(new InfiniteRuntimeClip(playable));
                graph.Connect(playable, 0, mixer, 0);
                mixer.SetInputWeight(0, 1.0f);
            }

            if (!AnimatesRootTransform())
            {
                return(mixer);
            }

            var rootTrack = isSubTrack ? (AnimationTrack)parent : this;

            return(rootTrack.ApplyTrackOffset(graph, mixer, go, mode));
        }
Exemplo n.º 2
0
        void AssignAnimationClip(TimelineClip clip, AnimationClip animClip)
        {
            if (clip == null || animClip == null)
            {
                return;
            }

            if (animClip.legacy)
            {
                throw new InvalidOperationException("Legacy Animation Clips are not supported");
            }

            AnimationPlayableAsset asset = clip.asset as AnimationPlayableAsset;

            if (asset != null)
            {
                asset.clip = animClip;
                asset.name = animClip.name;
                var duration = asset.duration;
                if (!double.IsInfinity(duration) && duration >= TimelineClip.kMinDuration && duration < TimelineClip.kMaxTimeValue)
                {
                    clip.duration = duration;
                }
            }
            clip.displayName = animClip.name;
        }
        void DeleteRecordedAnimation(TimelineClip clip)
        {
            if (clip == null)
            {
                return;
            }

            if (clip.curves != null)
            {
                TimelineUndo.PushDestroyUndo(this, clip.parentTrack, clip.curves);
            }

            if (!clip.recordable)
            {
                return;
            }

            AnimationPlayableAsset asset = clip.asset as AnimationPlayableAsset;

            if (asset == null || asset.clip == null)
            {
                return;
            }

            TimelineUndo.PushDestroyUndo(this, asset, asset.clip);
        }
Exemplo n.º 4
0
 private void AssignAnimationClip(TimelineClip clip, AnimationClip animClip)
 {
     if (clip != null && !(animClip == null))
     {
         if (animClip.legacy)
         {
             throw new InvalidOperationException("Legacy Animation Clips are not supported");
         }
         if (animClip.frameRate > 0f)
         {
             double num = (double)Mathf.Round(animClip.length * animClip.frameRate);
             clip.duration = num / (double)animClip.frameRate;
         }
         else
         {
             clip.duration = (double)animClip.length;
         }
         TimelineClip.ClipExtrapolation clipExtrapolation = TimelineClip.ClipExtrapolation.None;
         if (!base.isSubTrack)
         {
             clipExtrapolation = TimelineClip.ClipExtrapolation.Hold;
         }
         AnimationPlayableAsset animationPlayableAsset = clip.asset as AnimationPlayableAsset;
         if (animationPlayableAsset != null)
         {
             animationPlayableAsset.clip = animClip;
         }
         clip.preExtrapolationMode  = clipExtrapolation;
         clip.postExtrapolationMode = clipExtrapolation;
     }
 }
Exemplo n.º 5
0
        internal Playable CompileTrackPlayable(PlayableGraph graph, TrackAsset track, GameObject go, IntervalTree <RuntimeElement> tree)
        {
            AnimationMixerPlayable animationMixerPlayable = AnimationMixerPlayable.Create(graph, track.clips.Length, false);

            for (int i = 0; i < track.clips.Length; i++)
            {
                TimelineClip  timelineClip  = track.clips[i];
                PlayableAsset playableAsset = timelineClip.asset as PlayableAsset;
                if (!(playableAsset == null))
                {
                    if (timelineClip.recordable)
                    {
                        AnimationPlayableAsset animationPlayableAsset = playableAsset as AnimationPlayableAsset;
                        if (animationPlayableAsset != null)
                        {
                            animationPlayableAsset.removeStartOffset = !timelineClip.recordable;
                        }
                    }
                    Playable playable = playableAsset.CreatePlayable(graph, go);
                    if (playable.IsValid <Playable>())
                    {
                        RuntimeClip item = new RuntimeClip(timelineClip, playable, animationMixerPlayable);
                        tree.Add(item);
                        graph.Connect <Playable, AnimationMixerPlayable>(playable, 0, animationMixerPlayable, i);
                        animationMixerPlayable.SetInputWeight(i, 0f);
                    }
                }
            }
            return(this.ApplyTrackOffset(graph, animationMixerPlayable));
        }
Exemplo n.º 6
0
        internal override void OnCreateClipFromAsset(Object asset, TimelineClip clip)
        {
            AnimationClip animationClip = asset as AnimationClip;

            if (animationClip != null)
            {
                if (animationClip.legacy)
                {
                    throw new InvalidOperationException("Legacy Animation Clips are not supported");
                }
                AnimationPlayableAsset animationPlayableAsset = ScriptableObject.CreateInstance <AnimationPlayableAsset>();
                TimelineCreateUtilities.SaveAssetIntoObject(animationPlayableAsset, this);
                animationPlayableAsset.clip = animationClip;
                clip.asset = animationPlayableAsset;
                this.AssignAnimationClip(clip, animationClip);
            }
        }
Exemplo n.º 7
0
 private void DeleteRecordedAnimation(TimelineClip clip)
 {
     if (clip != null)
     {
         if (clip.curves != null)
         {
             TimelineUndo.PushDestroyUndo(this, clip.parentTrack, clip.curves, "Delete Parameters");
         }
         if (clip.recordable)
         {
             AnimationPlayableAsset animationPlayableAsset = clip.asset as AnimationPlayableAsset;
             if (!(animationPlayableAsset == null) && !(animationPlayableAsset.clip == null))
             {
                 TimelineUndo.PushDestroyUndo(this, animationPlayableAsset, animationPlayableAsset.clip, "Delete Recording");
             }
         }
     }
 }
        Playable CreateInfiniteTrackPlayable(PlayableGraph graph, GameObject go, IntervalTree <RuntimeElement> tree, AppliedOffsetMode mode)
        {
            if (m_InfiniteClip == null)
            {
                return(Playable.Null);
            }

            var mixer    = AnimationMixerPlayable.Create(graph, 1);
            var playable = AnimationPlayableAsset.CreatePlayable(graph, m_InfiniteClip, m_InfiniteClipOffsetPosition, m_InfiniteClipOffsetEulerAngles, false, mode, infiniteClipApplyFootIK);

            if (playable.IsValid())
            {
                tree.Add(new InfiniteRuntimeClip(playable));
                graph.Connect(playable, 0, mixer, 0);
                mixer.SetInputWeight(0, 1.0f);
            }

            return(ApplyTrackOffset(graph, mixer, go, mode));
        }
Exemplo n.º 9
0
        private Playable CreateInfiniteTrackPlayable(PlayableGraph graph, GameObject go, IntervalTree <RuntimeElement> tree)
        {
            Playable result;

            if (base.animClip == null)
            {
                result = Playable.Null;
            }
            else
            {
                if (this.m_FakeAnimClip == null || this.m_AnimationPlayableAsset == null)
                {
                    this.m_AnimationPlayableAsset = ScriptableObject.CreateInstance <AnimationPlayableAsset>();
                    this.m_FakeAnimClip           = new TimelineClip(null)
                    {
                        asset                 = this.m_AnimationPlayableAsset,
                        displayName           = "Animation Clip",
                        timeScale             = 1.0,
                        start                 = 0.0,
                        postExtrapolationMode = TimelineClip.ClipExtrapolation.Hold,
                        preExtrapolationMode  = TimelineClip.ClipExtrapolation.Hold
                    };
                    this.m_FakeAnimClip.SetPostExtrapolationTime(TimelineClip.kMaxTimeValue);
                }
                this.m_AnimationPlayableAsset.clip              = base.animClip;
                this.m_AnimationPlayableAsset.position          = this.m_OpenClipOffsetPosition;
                this.m_AnimationPlayableAsset.rotation          = this.m_OpenClipOffsetRotation;
                this.m_AnimationPlayableAsset.removeStartOffset = false;
                this.m_FakeAnimClip.start = 0.0;
                this.m_FakeAnimClip.SetPreExtrapolationTime(0.0);
                this.m_FakeAnimClip.duration = (double)base.animClip.length;
                AnimationMixerPlayable animationMixerPlayable = AnimationMixerPlayable.Create(graph, 1, false);
                Playable playable = this.m_AnimationPlayableAsset.CreatePlayable(graph, go);
                if (playable.IsValid <Playable>())
                {
                    tree.Add(new RuntimeClip(this.m_FakeAnimClip, playable, animationMixerPlayable));
                    graph.Connect <Playable, AnimationMixerPlayable>(playable, 0, animationMixerPlayable, 0);
                    animationMixerPlayable.SetInputWeight(0, 1f);
                }
                result = this.ApplyTrackOffset(graph, animationMixerPlayable);
            }
            return(result);
        }
Exemplo n.º 10
0
        internal bool AnimatesRootTransform()
        {
            // infinite mode
            if (AnimationPlayableAsset.HasRootTransforms(m_InfiniteClip))
            {
                return(true);
            }

            // clip mode
            foreach (var c in GetClips())
            {
                var apa = c.asset as AnimationPlayableAsset;
                if (apa != null && apa.hasRootTransforms)
                {
                    return(true);
                }
            }

            return(false);
        }
            public static void ConvertRotationToEuler(AnimationPlayableAsset asset)
            {
#pragma warning disable 618
                asset.m_EulerAngles = asset.m_Rotation.eulerAngles;
#pragma warning restore 618
            }