void copyNode(object obj) { FixClassCircleNoGo.Node node = obj as FixClassCircleNoGo.Node; if (node != null) { clipboardNode = FixClassCircleNoGo.DuplicateNode(node); } }
//draw data part bool Display(FixClassCircleNoGo.Node node) //return if Display should do next time { Rect titleRect = EditorGUILayout.BeginHorizontal(); string titlename = node.tagCh; if (!string.IsNullOrEmpty(node.tagCh)) { titlename += " / "; } titlename += node.tag; if (_target.ShowSize) { titlename += " / size:" + node.children.Count; } if (node.forSearch) { node.foldout = EditorGUILayout.Foldout(node.foldout, titlename, EditorStyles.foldoutPreDrop); } else { node.foldout = EditorGUILayout.Foldout(node.foldout, titlename); } if (node.editMode) { if (GUILayout.Button(forbutton6_2, EditorStyles.toolbarButton, GUILayout.Width(20))) { node.editMode = false; //重置搜索 node.searchStr = ""; foreach (var child in node.children) { child.forSearch = false; } _target.Record2SerializeOnce(); } } else { if (GUILayout.Button(forbutton6, GUILayout.Width(20))) { node.editMode = true; } } if (Event.current.isMouse && Event.current.button == 1 && titleRect.Contains(Event.current.mousePosition)) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Copy Node"), false, copyNode, node); if (node.father != null) { menu.AddItem(new GUIContent("Cut Node"), false, cutNode, node); } menu.AddItem(new GUIContent("Paste Node as a child"), false, pasteNode, node); menu.AddItem(new GUIContent("Empty clipboard"), false, emptyClipboard, null); menu.ShowAsContext(); Event.current.Use(); } if (GUILayout.Button(forbutton1, GUILayout.Width(20))) { node.children.Add(new FixClassCircleNoGo.Node(_target) { father = node }); _target.Record2SerializeOnce(); node.foldout = true; } /* * if (GUILayout.Button(forbutton2, GUILayout.Width(20))) * { * node.children.Clear(); * _target.Record2SerializeOnce(); * }*/ if (node.father != null) { if (GUILayout.Button(forbutton5, GUILayout.Width(22))) { FixClassCircleNoGo.Node nodetmp = FixClassCircleNoGo.DuplicateNode(node); nodetmp.father = node.father; int index = node.father.children.IndexOf(node); node.father.children.Insert(index, nodetmp); _target.Record2SerializeOnce(); return(true); } if (GUILayout.Button(forbutton3, GUILayout.Width(20))) { node.father.children.Remove(node); _target.Record2SerializeOnce(); return(true); } } EditorGUILayout.EndHorizontal(); if (!node.foldout) { EditorGUIUtility.labelWidth -= indentation; } if (node.editMode) { GUILayout.BeginHorizontal(); GUI.color = color_Edit; GUILayout.Space(indentation); node.tagCh = EditorGUILayout.TextField(node.tagCh, GUILayout.Width(90)); node.tag = EditorGUILayout.TextField(node.tag, GUILayout.Width(95)); if (GUILayout.Button(forbutton4, EditorStyles.radioButton, GUILayout.Width(20))) { FixClassCircle.ParamMore temp = _target.paramlist[node.paramIndex]; if (temp.Detail.Count > 0 && temp.Detail[0].type == FixClassCircle.ParamType.IntEnum) { string[] ss = temp.Detail[0].EnumDesc.Split(','); int index = 0; int.TryParse(node.otherParamValues[0], out index); node.tag = ss[index]; _target.Record2SerializeOnce(); } } //EditorGUILayout.LabelField("Struct", GUILayout.Width(40)); node.paramIndex = EditorGUILayout.Popup(node.paramIndex, getParamlistEnumStrArr(), GUILayout.Width(70)); if (node.paramIndex < 0) { node.paramIndex = 0; } node.searchStr = EditorGUILayout.TextField(node.searchStr, GUILayout.Width(70)); if (GUILayout.Button(forbutton7, GUILayout.Width(20))) { foreach (var child in node.children) { if (node.searchStr.Length > 0 && (child.tag.Contains(node.searchStr) || child.tagCh.Contains(node.searchStr))) { child.forSearch = true; } else { child.forSearch = false; child.foldout = false; } } } GUI.color = color_normal; GUILayout.EndHorizontal(); } if (!node.foldout) { return(false); } if (_target.paramlist.Count - 1 < node.paramIndex) { EditorGUIUtility.labelWidth -= indentation; return(false); //wait until list count is enough } for (int i = 0; i < _target.paramlist[node.paramIndex].Detail.Count && i < node.otherParamValues.Count; i++) { FixClassCircle.ParamType tempT = _target.paramlist[node.paramIndex].Detail[i].type; if (hidebelowparam && tempT != FixClassCircle.ParamType.BoolHideBelow && tempT != FixClassCircle.ParamType.BoolShowBelow) { continue; } GUILayout.BeginHorizontal(); GUILayout.Space(indentation + 13); drawParams(node, i); GUILayout.EndHorizontal(); } hidebelowparam = false; //--------------------------------------------------- GUILayout.BeginHorizontal(); GUILayout.Space(indentation); EditorGUIUtility.labelWidth -= indentation; GUILayout.BeginVertical(); foreach (var child in node.children) { if (Display(child) || forceQuitDraw) { forceQuitDraw = false; GUILayout.EndVertical(); GUILayout.EndHorizontal(); return(true); } EditorGUIUtility.labelWidth += indentation; // not plus not reduce } GUILayout.EndVertical(); GUILayout.EndHorizontal(); return(false); }