예제 #1
0
        public AnimatorPlayableObject(string graphName, Animator animator)
        {
            this.Animator            = animator;
            this.GlobalPlayableGraph = PlayableGraph.Create(graphName);
            this.GlobalPlayableGraph.SetTimeUpdateMode(DirectorUpdateMode.GameTime);
            var playableOutput = AnimationPlayableOutput.Create(this.GlobalPlayableGraph, "Animation", animator);

            this.AnimationLayerMixerPlayable = AnimationLayerMixerPlayable.Create(this.GlobalPlayableGraph);
            PlayableOutputExtensions.SetSourcePlayable(playableOutput, this.AnimationLayerMixerPlayable);
            this.GlobalPlayableGraph.Play();
        }
예제 #2
0
        public static AnimatorPlayable alloc(string p_graphName, Animator p_animator)
        {
            AnimatorPlayable l_instance = new AnimatorPlayable();

            l_instance.Animator            = p_animator;
            l_instance.GlobalPlayableGraph = PlayableGraph.Create(p_graphName);
            l_instance.GlobalPlayableGraph.SetTimeUpdateMode(DirectorUpdateMode.GameTime);
            var playableOutput = AnimationPlayableOutput.Create(l_instance.GlobalPlayableGraph, "Animation", p_animator);

            l_instance.AnimationLayerMixerPlayable = AnimationLayerMixerPlayable.Create(l_instance.GlobalPlayableGraph);
            PlayableOutputExtensions.SetSourcePlayable(playableOutput, l_instance.AnimationLayerMixerPlayable);
            l_instance.GlobalPlayableGraph.Play();
            return(l_instance);
        }
예제 #3
0
 public static void AddDefaultHumanoidTrack(PlayableGraph graph, Playable rootPlayable, Animator animator)
 {
     if (!(AnimationDefaultTrack.defaultHumanoidClip == null))
     {
         Playable playable = new Playable(AnimationPlayableGraphExtensions.CreateAnimationMotionXToDeltaPlayable(graph));
         PlayableExtensions.SetInputCount <Playable>(playable, 1);
         AnimationOffsetPlayable animationOffsetPlayable = AnimationOffsetPlayable.Create(graph, Vector3.get_zero(), Quaternion.get_identity(), 1);
         AnimationClipPlayable   animationClipPlayable   = AnimationClipPlayable.Create(graph, AnimationDefaultTrack.defaultHumanoidClip);
         PlayableExtensions.SetTime <AnimationClipPlayable>(animationClipPlayable, 0.0);
         PlayableExtensions.SetSpeed <AnimationClipPlayable>(animationClipPlayable, 0.0);
         graph.Connect <AnimationOffsetPlayable, Playable>(animationOffsetPlayable, 0, playable, 0);
         PlayableExtensions.SetInputWeight <Playable>(playable, 0, 1f);
         graph.Connect <AnimationClipPlayable, AnimationOffsetPlayable>(animationClipPlayable, 0, animationOffsetPlayable, 0);
         PlayableExtensions.SetInputWeight <AnimationOffsetPlayable>(animationOffsetPlayable, 0, 1f);
         int inputCount = PlayableExtensions.GetInputCount <Playable>(rootPlayable);
         PlayableExtensions.SetInputCount <Playable>(rootPlayable, inputCount + 1);
         graph.Connect <Playable, Playable>(playable, 0, rootPlayable, inputCount);
         PlayableExtensions.SetInputWeight <Playable>(rootPlayable, inputCount, 1f);
         AnimationPlayableOutput animationPlayableOutput = AnimationPlayableOutput.Create(graph, "DefaultHumanoid", animator);
         PlayableOutputExtensions.SetSourcePlayable <AnimationPlayableOutput, Playable>(animationPlayableOutput, rootPlayable);
         PlayableOutputExtensions.SetSourceInputPort <AnimationPlayableOutput>(animationPlayableOutput, inputCount);
     }
 }
예제 #4
0
 private void CreateTrackOutput(PlayableGraph graph, TrackAsset track, Playable playable, int port)
 {
     if (!track.isSubTrack)
     {
         IEnumerable <PlayableBinding> outputs = track.get_outputs();
         foreach (PlayableBinding current in outputs)
         {
             if (current.get_streamType() == null)
             {
                 AnimationPlayableOutput animationPlayableOutput = AnimationPlayableOutput.Create(graph, current.get_streamName(), null);
                 PlayableOutputExtensions.SetReferenceObject <AnimationPlayableOutput>(animationPlayableOutput, current.get_sourceObject());
                 PlayableOutputExtensions.SetSourcePlayable <AnimationPlayableOutput, Playable>(animationPlayableOutput, playable);
                 PlayableOutputExtensions.SetSourceInputPort <AnimationPlayableOutput>(animationPlayableOutput, port);
                 this.m_EvaluateCallbacks.Add(new AnimationOutputWeightProcessor(animationPlayableOutput));
             }
             else if (current.get_streamType() == 1)
             {
                 AudioPlayableOutput audioPlayableOutput = AudioPlayableOutput.Create(graph, current.get_streamName(), null);
                 PlayableOutputExtensions.SetReferenceObject <AudioPlayableOutput>(audioPlayableOutput, current.get_sourceObject());
                 PlayableOutputExtensions.SetSourcePlayable <AudioPlayableOutput, Playable>(audioPlayableOutput, playable);
                 PlayableOutputExtensions.SetSourceInputPort <AudioPlayableOutput>(audioPlayableOutput, port);
             }
             else
             {
                 if (current.get_streamType() != 3)
                 {
                     throw new NotImplementedException("Unsupported stream type");
                 }
                 ScriptPlayableOutput scriptPlayableOutput = ScriptPlayableOutput.Create(graph, current.get_streamName());
                 PlayableOutputExtensions.SetReferenceObject <ScriptPlayableOutput>(scriptPlayableOutput, current.get_sourceObject());
                 PlayableOutputExtensions.SetSourcePlayable <ScriptPlayableOutput, Playable>(scriptPlayableOutput, playable);
                 PlayableOutputExtensions.SetSourceInputPort <ScriptPlayableOutput>(scriptPlayableOutput, port);
             }
         }
     }
 }