Beispiel #1
0
    // Checked before OnGUI()
    public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
    {
        if (!allAttributes.NotNullOrEmpty())
        {
            allAttributes = fieldInfo.GetCustomAttributes(typeof(PropertyAttribute), false).Cast <PropertyAttribute>()
                            .ToList();
        }

        if (allAttributes.Count > 1)
        {
            if (hideIfNotEnumAttr == null)
            {
                hideIfNotEnumAttr =
                    allAttributes.Find(attr => attr is HideIfNotEnumValuesAttribute) as HideIfNotEnumValuesAttribute;
            }

            // skip drawing if not highest order (one-time draw execution check)
            if (!attribute.HasHighestOrder(allAttributes))
            {
                // removes empty space instead of "not drawn" property
                return(-EditorGUIUtility.standardVerticalSpacing);
            }

            return(HideIfNotEnumValuesPropertyDrawer.IsAllowed(hideIfNotEnumAttr, property)
                ? EditorGUI.GetPropertyHeight(property, label)
                   // removes empty space instead of "not drawn" property
                : -EditorGUIUtility.standardVerticalSpacing);
        }

        return(EditorGUI.GetPropertyHeight(property, label));
    }
Beispiel #2
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        if (allAttributes.Count > 1)
        {
            // skip drawing if not highest order (one-time draw execution check)
            if (!attribute.HasHighestOrder(allAttributes))
            {
                return;
            }

            // HideIfNotEnumValuesAttribute check
            if (hideIfNotEnumAttr != null)
            {
                if (HideIfNotEnumValuesPropertyDrawer.IsAllowed(hideIfNotEnumAttr, property))
                {
                    DrawProp(position, property, label);
                }
            }
        }
        else
        {
            DrawProp(position, property, label);
        }
    }