private void CreateNodeFromAnimationClip(AnimationClip clip, UnityEditor.Graphs.AnimationBlendTree.Node parentNode) { UnityEditor.Graphs.AnimationBlendTree.Node node = this.CreateNode(clip, clip.name); node.parent = parentNode; Slot fromSlot = parentNode.AddOutputSlot(clip.name); Slot toSlot = node.AddInputSlot((parentNode.motion as BlendTree).name); this.Connect(fromSlot, toSlot); }
private void CreateNodeFromBlendTreeRecursive(BlendTree blendTree, UnityEditor.Graphs.AnimationBlendTree.Node parentNode) { UnityEditor.Graphs.AnimationBlendTree.Node node = this.CreateNode(blendTree, blendTree.name); if (parentNode != null) { node.parent = parentNode; Slot fromSlot = parentNode.AddOutputSlot(blendTree.name); Slot toSlot = node.AddInputSlot((parentNode.motion as BlendTree).name); this.Connect(fromSlot, toSlot); } else { this.m_RootBlendTree = blendTree; this.m_RootNode = node; } int childCount = blendTree.GetChildCount(); for (int i = 0; i < childCount; i++) { Motion childMotion = blendTree.GetChildMotion(i); if (childMotion == null) { this.CreateEmptySlot(node); } else if (childMotion is BlendTree) { this.CreateNodeFromBlendTreeRecursive(childMotion as BlendTree, node); } else { if (!(childMotion is AnimationClip)) { throw new NotImplementedException("Unknown Motion type:" + childMotion.GetType()); } this.CreateNodeFromAnimationClip(childMotion as AnimationClip, node); } } }