예제 #1
0
    public AnimationPlayableInstance(Animator _animator, AnimationPlayableBaseNode node)
    {
        animator = _animator;

        mixer = AnimationMixerPlayable.Create();

        AnimationClip c = node.Inputs[0].GetValue <AnimationClip>();

        AnimationClip[] sources = node.Inputs.Select(x => x.GetValue <AnimationClip>()).ToArray();
        mixer.SetInputs(sources);
    }
    void Start()
    {
        Animator animator = GetComponent <Animator>();

        // Load NodeCanvas asset
        var path   = "Assets/Plugins/Node_Editor/Resources/Saves/PlayableCanvas.asset";
        var canvas = NodeEditorSaveManager.LoadNodeCanvas(path, false);

        // Set input/output values on runtime, otherwise all input/output have null
        foreach (Node n in canvas.nodes)
        {
            n.Calculate();
        }

        // Find AnimationPlayableMixerNode
        AnimationPlayableBaseNode node = FindNode(canvas);

        playableInst = new AnimationPlayableInstance(animator, node);

        // Mixing animations.
        playableInst.Execute();
    }