protected override void OnControlGUI(Rect position) { EditorGUI.BeginChangeCheck(); LudiqGUI.TypeTreeField(ref position, GUIContent.none, rootTypeTree, !hideRoot, GetOptions); if (EditorGUI.EndChangeCheck()) { var newType = rootTypeTree.GetSubstitutedType(); accessor.RecordUndo(); accessor.value = newType; } }
protected override void OnControlGUI(Rect position) { InferType(); var showLabels = !adaptiveWidth && position.width >= 120; if (chooseType) { var x = position.x; var remainingWidth = position.width; if (showLabels) { var typeLabel = label == GUIContent.none ? new GUIContent("Type") : new GUIContent(label.text + " Type"); var typeLabelPosition = new Rect ( x, y, Styles.labelWidth, EditorGUIUtility.singleLineHeight ); GUI.Label(typeLabelPosition, typeLabel, labelStyle); x += typeLabelPosition.width; remainingWidth -= typeLabelPosition.width; } var typePosition = new Rect ( x, y, remainingWidth, LudiqGUI.GetTypeTreeFieldHeight(typeTree) ); EditorGUI.BeginChangeCheck(); LudiqGUI.TypeTreeField(ref typePosition, GUIContent.none, typeTree, true, GetTypeOptions, Contents.nullTypeLabel); if (EditorGUI.EndChangeCheck()) { var newType = typeTree.GetSubstitutedType(); accessor.RecordUndo(); typeTree.ChangeType(newType); EnforceType(); SetHeightDirty(); } y += typePosition.height; } if (chooseType && showValue) { y += Styles.spaceBetweenTypeAndValue; } if (showValue) { Rect valuePosition; if (chooseType) { var x = position.x; var remainingWidth = position.width; if (showLabels) { var valueLabel = label == GUIContent.none ? new GUIContent("Value") : new GUIContent(label.text + " Value"); var valueLabelPosition = new Rect ( x, y, Styles.labelWidth, EditorGUIUtility.singleLineHeight ); GUI.Label(valueLabelPosition, valueLabel, labelStyle); x += valueLabelPosition.width; remainingWidth -= valueLabelPosition.width; } valuePosition = new Rect ( x, y, remainingWidth, castedInspector.ControlHeight(remainingWidth) ); castedInspector.DrawControl(valuePosition); } else { valuePosition = new Rect ( position.x, y, position.width, castedInspector.ControlHeight(position.width) ); castedInspector.DrawControl(valuePosition); } y += valuePosition.height; } else { accessor.value = null; } }