private bool TryAddNewPair(PropertyWrapper wrapper, SerializedProperty newKey) { bool suchKeyExists = false; for (int i = 0; i < wrapper.Count; i++) { var curKey = wrapper.GetKeyAtIndex(i); if (Holder.KeysAreEqual(curKey, newKey)) { suchKeyExists = true; } } if (!suchKeyExists) { int curSize = wrapper.Count; wrapper.InsertPairAtIndex(curSize); Holder.PutValue(wrapper.GetKeyAtIndex(curSize)); wrapper.Apply(); return(true); } else { CustomDebug.LogError("Key already exists " + newKey.ToString()); return(false); } }
private bool DrawOneElement(ref Rect inputRect, PropertyWrapper wrapper, int index) { Rect currentRect = RectExtention.CutRectVertical(ref inputRect, wrapper.GetElementHeight(index)); Rect buttonRect = RectExtention.CutRectHorizontal(ref currentRect, TotalLineSpacing); buttonRect.width = buttonRect.height = EditorGUIUtility.singleLineHeight; if (GUI.Button(buttonRect, "-")) { wrapper.DeletePairAtIndex(index); return(false); } else { EditorGUI.BeginDisabledGroup(true); { EditorGUI.PropertyField(RectExtention.CutRectHorizontalRelative(ref currentRect, 0.3f), wrapper.GetKeyAtIndex(index), GUIContent.none, true); } EditorGUI.EndDisabledGroup(); EditorGUI.indentLevel++; { EditorGUI.PropertyField(currentRect, wrapper.GetValueAtIndex(index), GUIContent.none, true); } EditorGUI.indentLevel--; return(true); } }