public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { ConditionalHideIntCustomDisplayAttribute condHAtt = (ConditionalHideIntCustomDisplayAttribute)attribute; bool enabled = GetConditionalHideAttributeResult(condHAtt, property); //if (!condHAtt.HideInInspector || enabled) if (condHAtt.Behavior != ConditionalHideBehavior.Hide || enabled) { //return EditorGUI.GetPropertyHeight(property, label); property.isExpanded = true; float bodyHeight = (EditorGUI.GetPropertyHeight(property, label, true) - EditorGUI.GetPropertyHeight(property, label, false) - EditorGUIUtility.standardVerticalSpacing); switch (condHAtt.DisplayMode) { case CustomDisplayMode.NoLabel: return(bodyHeight); case CustomDisplayMode.LabelAsHeader: return(bodyHeight + EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing); case CustomDisplayMode.NoDropdown: return(EditorGUI.GetPropertyHeight(property, label, true)); default: return(0f); } } else { //The property is not being drawn //We want to undo the spacing added before and after the property return(-EditorGUIUtility.standardVerticalSpacing); } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { ConditionalHideIntCustomDisplayAttribute condHAtt = (ConditionalHideIntCustomDisplayAttribute)attribute; bool enabled = GetConditionalHideAttributeResult(condHAtt, property); bool wasEnabled = GUI.enabled; GUI.enabled = enabled; //if (!condHAtt.HideInInspector || enabled) if (condHAtt.Behavior != ConditionalHideBehavior.Hide || enabled) { property.isExpanded = true; SerializedProperty endProperty = property.GetEndProperty(); switch (condHAtt.DisplayMode) { case CustomDisplayMode.NoLabel: break; case CustomDisplayMode.LabelAsHeader: position = PropertyDrawerUtil.DrawLabel(label, position, EditorStyles.boldLabel); break; case CustomDisplayMode.NoDropdown: position = PropertyDrawerUtil.DrawLabel(label, position); break; } property.NextVisible(true); do { position = PropertyDrawerUtil.DrawProperty(property, position, true); property.NextVisible(false); } while (!SerializedProperty.EqualContents(property, endProperty)); } GUI.enabled = wasEnabled; }