AnimationLayerMixerPlayable with multiple ScriptPlayable inputs

Hi there!

I’m trying to use the Playable API, and more specifically mix the result of multiple ScriptPlayable with an AnimationLayerMixerPlayable.

It unfortunately works partially, in the sense that only the first ScriptPlayable seems to be evaluated, and other ScriptPlayable have just no effect.

Any idea? Thanks!

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Animations;
using UnityEngine.Playables;

public class MyPlayable : PlayableBehaviour
{
    string name = "";
    AnimationClip clip;
    AnimationClipPlayable clipPlayable;
    Playable mixerPlayable;

    public void Initialize(string playableName, Playable scriptPlayableOwner, PlayableGraph playableGraph, AnimationClip animationClip)
    {
        name = playableName;

        // Create playable animation-clip.
        clip = animationClip;
        clipPlayable = AnimationClipPlayable.Create(playableGraph, clip);

        // Create playable mixer, and add playable animation-clip to mixer inputs.
        mixerPlayable = AnimationMixerPlayable.Create(playableGraph);
        mixerPlayable.AddInput(clipPlayable, 0);
        // Configure mixer input.
        mixerPlayable.SetInputWeight(0, 1.0f);

        // Add playable mixer to playable-script inputs.
        scriptPlayableOwner.AddInput(mixerPlayable, 0);
        // Configure playable-script input.
        scriptPlayableOwner.SetInputWeight(0, 1.0f);
    }

    public override void PrepareFrame(Playable owner, FrameData info)
    {
        Debug.Log("MyPlayable.PrepareFrame - " + name);
    }
}

class MyBehaviour : MonoBehaviour
{
    public AnimationClip[] clips;

    PlayableGraph playableGraph;
    AnimationLayerMixerPlayable layerMixerPlayable;
    List<ScriptPlayable<MyPlayable>> scriptPlayables = new List<ScriptPlayable<MyPlayable>>();
    AnimationPlayableOutput playableOutput;

    void Start()
    {
        InitializeGraph(clips);
    }

    void InitializeGraph(AnimationClip[] clips)
    {
        // Create the graph.
        playableGraph = PlayableGraph.Create();
        GraphVisualizerClient.Show(playableGraph, "MyPlayableGraph");

        // Create the layer mixer that will mix multiple ScriptPlayable<MyPlayable> outputs.
        layerMixerPlayable = AnimationLayerMixerPlayable.Create(playableGraph);

        // Create a ScriptPlayable<MyPlayable> for each clip.
        foreach (AnimationClip clip in clips)
        {
            // Create ScriptPlayable of MyPlayable.
            ScriptPlayable<MyPlayable> myPlayableScript = ScriptPlayable<MyPlayable>.Create(playableGraph);
            MyPlayable myPlayable = myPlayableScript.GetBehaviour();
            string myPlayableName = "MyPlayable" + layerMixerPlayable.GetInputCount().ToString();
            myPlayable.Initialize(myPlayableName, myPlayableScript, playableGraph, clip);
            scriptPlayables.Add(myPlayableScript);

            // Add script-playable to mixer inputs.
            layerMixerPlayable.AddInput(myPlayableScript, 0);

            // Configure mixer input.
            int playableIndex = layerMixerPlayable.GetInputCount() - 1;
            layerMixerPlayable.SetInputWeight(playableIndex, 1.0f);
            layerMixerPlayable.SetLayerAdditive((uint)playableIndex, true);
        }

        // Create output, and assign the mixer to its source.
        playableOutput = AnimationPlayableOutput.Create(playableGraph, "Animation", gameObject.GetComponent<Animator>());
        playableOutput.SetSourcePlayable(layerMixerPlayable);

        // Play the graph.
        playableGraph.Play();
    }

    void OnDestroy()
    {
        scriptPlayables.Clear();
        playableGraph.Destroy();   
    }
}

i have this same issue when i tried to plug multiple animation clips inputs into scriptplayable then into layermixer… only fist input animation go through from each scriptable playable… the rest of inputs are not evaluated although they show playing when inspecting them.

Can someone confirm if this is an intended design or a bug?
or if there is a right way to plug multiple inputs and mix them in ScriptPlayables?