public bool DrawTreeNode(TreeViewNode n) { float spacePixelsPerLevel = 10f; float offset = 10f; nodeContent = new GUIContent(); EditorGUILayout.BeginHorizontal(); GUILayout.Space(offset); foreach (var p in n.state.userParams) { if (p.param.GetType() == typeof(bool)) { EditorGUILayout.LabelField(p.desc, toggleLabelStyle, GUILayout.Width(toggleLabelStyle.CalcSize(new GUIContent(p.desc)).x)); bool newState = EditorGUILayout.Toggle((bool)p.param, toggleStyle, new GUILayoutOption[] { GUILayout.MaxWidth(20f) }); if (newState != (bool)p.param) { currCtrl.frameTriggerInfo.isValueChanged = true; currCtrl.frameTriggerInfo.isCtrlBehaveChange = true; currCtrl.lastValueChangeNodePath = n.GetPathString(); currCtrl.CurrValue = n; } p.param = newState; } } GUILayout.Space(offset + spacePixelsPerLevel * (float)n.Level()); if (n.IsLeaf()) { n.state.IsExpand = false; } bool newExpandState = false; nodeContent.text = n.name; if (n.image != null) { nodeContent.image = n.image; } if (n.tooptip != "") { nodeContent.tooltip = n.tooptip; } if (n.IsLeaf()) {//叶节点绘制直接使用标签 GUILayout.Space(14f); EditorGUILayout.LabelField(nodeContent, labelStyle, GUILayout.Width(labelStyle.CalcSize(nodeContent).x)); } else { newExpandState = EditorGUILayout.Foldout(n.state.IsExpand, nodeContent, foldOutStyle); } SpecialEffectEditorUtility.GetLastRect(ref n.lastLabelRect); //若节点展开状态有变化则重绘 if (newExpandState != n.state.IsExpand) { currCtrl.frameTriggerInfo.isCtrlBehaveChange = true; RequestRepaint(); } if (currCtrl.Enable) { n.state.IsExpand = newExpandState; } //被选中节点绘制选中方形 if (n.Equals(currCtrl.currSelectNode)) { GUI.Box(n.lastRect, GUIContent.none); if (n.lastRect.size == new Vector2(0, 0)) { RequestRepaint(); } } EditorGUILayout.EndHorizontal(); SpecialEffectEditorUtility.GetLastRect(ref n.lastRect); HandleMouseInput(n); //若当前节点没有展开则略过此节点子树渲染 if (!n.state.IsExpand) { return(false); } return(true); }