public void CopyTo(MGNodeSet target) { FillnodeTypeCollectionMap(); target.FillnodeTypeCollectionMap(); foreach (var item in nodeTypeCollectionMap) { item.Value.CopyTo(target.nodeTypeCollectionMap[item.Key]); } target.map.Clear(); target.map.AddRange(map); }
public MGNodeSetEditor(SerializedProperty nodeSetProperty, MGNodeSet nodeSet) { this.nodeSet = nodeSet; this.nodeSetProperty = nodeSetProperty; rList = new ReorderableList(nodeSetProperty.serializedObject, nodeSetProperty.FindPropertyRelative("map"), true, false, true, false) { drawElementCallback = DrawElementHandler, elementHeightCallback = (int index) => { if (index >= nodeSet.map.Count) { return(0); } var prop = GetNodeProp(index); float h = 20; //foreach (var item in prop.GetChildren()) //{ // h += EditorGUI.GetPropertyHeight(item, true); //} if (prop != null) { h += EditorGUI.GetPropertyHeight(prop, true); } if (h < 60) { h = 60; } return(h); }, onAddDropdownCallback = (Rect rect, ReorderableList list) => { ShowAddNodeContextMenu(); }, drawHeaderCallback = (rect) => { rect.x += 10; rect.width -= 10; EditorGUI.PropertyField(new Rect(rect.x, rect.y, rect.width / 2f, rect.height), nodeSetProperty, false); float bw = rect.width / 2f / 3f; float bx = rect.x + rect.width / 2f; const string mgNodeSetBufferPrefix = "MGNodeSetBuffer"; if (!string.IsNullOrEmpty(EditorGUIUtility.systemCopyBuffer) && EditorGUIUtility.systemCopyBuffer.IndexOf(mgNodeSetBufferPrefix) == 0 && GUI.Button(new Rect(bx, rect.y, bw, rect.height), "Paste")) { Undo.RecordObject(nodeSetProperty.serializedObject.targetObject, "Paste"); var tmpBuffer = new MGNodeSet(); EditorJsonUtility.FromJsonOverwrite(EditorGUIUtility.systemCopyBuffer.Substring(mgNodeSetBufferPrefix.Length), tmpBuffer); tmpBuffer.CopyTo(nodeSet); } bx += bw; if (GUI.Button(new Rect(bx, rect.y, bw, rect.height), "Copy")) { EditorGUIUtility.systemCopyBuffer = mgNodeSetBufferPrefix + EditorJsonUtility.ToJson(nodeSet); } bx += bw; if (GUI.Button(new Rect(bx, rect.y, bw, rect.height), "Clear")) { Undo.RecordObject(nodeSetProperty.serializedObject.targetObject, "Clear"); nodeSet.Clear(); } } }; }