コード例 #1
0
        public BlendTree2d(PlayableGraph graph, List <BlendSpaceNode> nodes)
        {
            m_Nodes = nodes;

            var count = m_Nodes.Count;

            m_Positions = new Vector2[count];
            m_Clips     = new AnimationClipPlayable[count];
            m_Weights   = new float[count];

            m_Mixer = AnimationMixerPlayable.Create(graph, count);
            m_Mixer.SetPropagateSetTime(true);

            for (var i = 0; i < count; i++)
            {
                var node = m_Nodes[i];
                var clip = AnimationClipPlayable.Create(graph, node.clip);
                node.clipLength = node.clip.length;
                clip.Play();
                m_Mixer.ConnectInput(i, clip, 0);
                m_Clips[i] = clip;
                m_Nodes[i] = node;
            }

            masterSpeed = 1f;
            SetBlendPosition(Vector2.zero);
        }