// 获取鼠标所在位置的节点 private SkillHsmConfigNodeData GetMouseInNode(List <SkillHsmConfigNodeData> nodeList) { SkillHsmConfigNodeData selectNode = null; for (int i = 0; i < nodeList.Count; i++) { SkillHsmConfigNodeData nodeValue = nodeList[i]; // 如果鼠标位置 包含在 节点的 Rect 范围,则视为可以选择的节点 if (RectTExtension.RectTToRect(nodeValue.Position).Contains(mousePosition)) { selectNode = nodeValue; break; } } return(selectNode); }
// 绘制节点 private void DrawNodeWindows() { Action CallBack = () => { for (int i = 0; i < _nodeList.Count; i++) { SkillHsmConfigNodeData nodeValue = _nodeList[i]; int index = EnumNames.GetEnumIndex <NODE_TYPE>((NODE_TYPE)nodeValue.NodeType); string name = EnumNames.GetEnumName <NODE_TYPE>(index); name = string.Format("{0}_{1}", name, nodeValue.Id); Rect rect = GUI.Window(i, RectTExtension.RectTToRect(nodeValue.Position), DrawNodeWindow, name); nodeValue.Position = RectTExtension.RectToRectT(rect); DrawToChildCurve(nodeValue); } }; _treeNodeWindow.DrawWindow(CallBack); }