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); } }
private void DrawAddControl(ref Rect inputRect, PropertyWrapper wrapper) { Rect currentRect = RectExtention.CutRectVertical(ref inputRect, AddControlHeight); EditorGUI.PropertyField(RectExtention.CutRectHorizontalRelative(ref currentRect, 0.8f), currentNewKey, GUIContent.none); SerializedHolder.ApplyModifiedProperties(); if (GUI.Button(currentRect, "Add")) { TryAddNewPair(wrapper, currentNewKey); } }
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label) { Rect currentRect = pos; popOverToggle = EditorGUI.Foldout(RectExtention.CutRectVertical(ref currentRect, FoldOutHeight), popOverToggle, label, true); if (popOverToggle) { PropertyWrapper curWrapper = new PropertyWrapper(prop); DrawAddControl(ref currentRect, curWrapper); DrawElements(ref currentRect, curWrapper); } }