static AudioMixerPlayable CreateAudioBinding(PlayableGraph graph, AudioSource audioSource) { var mixerPlayable = AudioMixerPlayable.Create(graph, 1); var output = (AudioPlayableOutput)graph.GetOutputByType <AudioPlayableOutput>(0); if (!output.IsOutputNull()) { output.SetTarget(audioSource); output.SetSourcePlayable(mixerPlayable); Assert.IsTrue(output.IsOutputValid()); } return(mixerPlayable); }
static AnimationMixerPlayable CreateAnimationBinding(PlayableGraph graph, Animator animator) { var mixerPlayable = AnimationMixerPlayable.Create(graph, 1); var output = (AnimationPlayableOutput)graph.GetOutputByType <AnimationPlayableOutput>(0); if (!output.IsOutputNull()) { output.SetTarget(animator); output.SetSourcePlayable(mixerPlayable); Assert.IsTrue(output.IsOutputValid()); } return(mixerPlayable); }
void Setup1() { animator = GetComponent <Animator>(); playableGraph = animator.playableGraph; playableGraph.Stop(); var playableOutput = playableGraph.GetOutputByType <AnimationPlayableOutput>(0); var controllerPlayable = playableOutput.GetSourcePlayable(); // Mixer var mixer = AnimationMixerPlayable.Create(playableGraph, 2, false); playableGraph.Connect(controllerPlayable, 0, mixer, 0); // Setup output playableOutput.SetSourcePlayable(mixer); }