AddChild() public method

Utility function to add a child motion to a blend trees.

public AddChild ( Motion motion ) : void
motion UnityEngine.Motion The motion to add as child.
return void
示例#1
0
 private void CreateMotionCallback(object obj)
 {
     UnityEditor.Animations.BlendTree tree = obj as UnityEditor.Animations.BlendTree;
     if (tree != null)
     {
         tree.AddChild(null);
         tree.SetDirectBlendTreeParameter(tree.children.Length - 1, this.m_Tool.animatorController.GetDefaultBlendTreeParameter());
     }
 }
示例#2
0
    private void FillAnimatorState(int depth, UnityEditor.Animations.AnimatorStateMachine stateMachine)
    {
        foreach (var sta in stateMachine.stateMachines)
        {
            Debug.Log("Depth=" + depth + " stateMachines " + sta.stateMachine);
            FillAnimatorState(depth + 1, sta.stateMachine);
        }

        foreach (UnityEditor.Animations.ChildAnimatorState sta in stateMachine.states)
        {
            UnityEditor.Animations.BlendTree blendTree = sta.state.motion as UnityEditor.Animations.BlendTree;
            if (blendTree != null)
            {
                Debug.LogError("Depth=" + depth + " blendTree need to be refined" + sta.state.motion);
                int mCount = blendTree.children.Length;

                //foreach (var cmotion in blendTree.children)
                for (int i = 0; i < mCount; i++)
                {
                    Debug.Log("Blend Clip " + blendTree.children[i].motion);
                    Vector2 position = blendTree.children[i].position;
                    blendTree.AddChild(emptyClip, position);
                }
                for (int i = 0; i < mCount; i++)
                {
                    blendTree.RemoveChild(0);
                }
                sta.state.motion = blendTree;
            }
            else
            {
                Debug.Log("Depth=" + depth + " Clip " + sta.state.motion);
                sta.state.motion = emptyClip;
            }
        }
    }