private void AddNewBlendTreeCallback() { Motion stateEffectiveMotion = AnimatorControllerTool.tool.animatorController.GetStateEffectiveMotion(this.state, AnimatorControllerTool.tool.selectedLayerIndex); BlendTree blendTree = stateEffectiveMotion as BlendTree; AnimatorStateMachine stateMachine = AnimatorControllerTool.tool.animatorController.layers[AnimatorControllerTool.tool.selectedLayerIndex].stateMachine; bool flag = true; if (blendTree != null) { string title = "This will delete current BlendTree in state."; string message = "You cannot undo this action."; if (EditorUtility.DisplayDialog(title, message, "Delete", "Cancel")) { MecanimUtilities.DestroyBlendTreeRecursive(blendTree); } else { flag = false; } } else { Undo.RegisterCompleteObjectUndo(stateMachine, "Blend Tree Added"); } if (flag) { BlendTree blendTree2 = new BlendTree(); blendTree2.hideFlags = HideFlags.HideInHierarchy; if (AssetDatabase.GetAssetPath(AnimatorControllerTool.tool.animatorController) != string.Empty) { AssetDatabase.AddObjectToAsset(blendTree2, AssetDatabase.GetAssetPath(AnimatorControllerTool.tool.animatorController)); } blendTree2.name = "Blend Tree"; BlendTree arg_10B_0 = blendTree2; string defaultBlendTreeParameter = AnimatorControllerTool.tool.animatorController.GetDefaultBlendTreeParameter(); blendTree2.blendParameterY = defaultBlendTreeParameter; arg_10B_0.blendParameter = defaultBlendTreeParameter; AnimatorControllerTool.tool.animatorController.SetStateEffectiveMotion(this.state, blendTree2, AnimatorControllerTool.tool.selectedLayerIndex); } }
public void RemoveNodeMotions(IEnumerable <UnityEditor.Graphs.Node> nodes) { foreach (UnityEditor.Graphs.Node current in nodes) { Node node = current as Node; if (!(this.m_RootBlendTree == node.motion)) { if (!(node.motion == null)) { if (node.parent) { BlendTree blendTree = node.parent.motion as BlendTree; int index = Graph.FindMotionIndexOnBlendTree(blendTree, node.motion); blendTree.RemoveChild(index); } BlendTree blendTree2 = node.motion as BlendTree; if (blendTree2 && MecanimUtilities.AreSameAsset(this.m_RootBlendTree, blendTree2)) { MecanimUtilities.DestroyBlendTreeRecursive(blendTree2); } } } } }