public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { if (m_Attr == null) { m_Attr = (HidePropertyIfAttribute)attribute; } EvaluateVisibility(property); if (m_Hidden && m_Attr.visibilityBehaviour == HidePropertyIfAttribute.Visibility.Hide) { return(0f); } return(base.GetPropertyHeight(property, label)); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { if (m_Attr == null) { m_Attr = (HidePropertyIfAttribute)attribute; } EvaluateVisibility(property); // If the condition is met, simply draw the field. if (!m_Hidden) { EditorGUI.PropertyField(position, property); } else if (m_Attr.visibilityBehaviour == HidePropertyIfAttribute.Visibility.Lock) { GUI.enabled = false; EditorGUI.PropertyField(position, property); GUI.enabled = true; } }