Example #1
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);
     }
 }
Example #2
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);
             }
         }
     }
 }