コード例 #1
0
    public override float GetPropertyHeight(SerializedPropertyX property, GUIContent label)
    {
        float slh = EditorGUIUtility.singleLineHeight;

        if (property.isExpanded)
        {
            PropertyDrawerX     minDrawerX = Reflector.GetCustomPropertyDrawerFor(property["min"]);
            PropertyDrawerX     maxDrawerX = Reflector.GetCustomPropertyDrawerFor(property["max"]);
            SerializedPropertyX min        = property["min"];
            SerializedPropertyX max        = property["max"];
            return(2f * slh + (minDrawerX.GetPropertyHeight(min, min.label) + maxDrawerX.GetPropertyHeight(max, max.label)));
        }
        else
        {
            return(slh);
        }
    }
コード例 #2
0
    //todo account for decorators eventually
    public static float GetHeight(SerializedPropertyX property, GUIContent label, bool includeChildren)
    {
        PropertyDrawerX drawerX = Reflector.GetCustomPropertyDrawerFor(property);

        if (drawerX != null)
        {
            return(drawerX.GetPropertyHeight(property, label));
        }
        else if (!includeChildren || property.type.IsPrimitive || property.type.IsEnum || property.type == typeof(string) || Array.IndexOf(BuildInTypes, property.type) != -1)
        {
            return(GetSinglePropertyHeight(property.type, label));
        }
        else if (property.type.IsArray)
        {
            if (property.isExpanded)
            {
                float height = 32f;
                for (int i = 0; i < property.ChildCount; i++)
                {
                    SerializedPropertyX child = property.GetChildAt(i);
                    height += GetHeight(child, child.label, child.isExpanded);
                }
                return(height);
            }
            return(16f);
        }
        else
        {
            float height = 16f;
            for (int i = 0; i < property.ChildCount; i++)
            {
                SerializedPropertyX child = property.GetChildAt(i);
                height += GetHeight(child, child.label, child.isExpanded);
            }
            return(height);
        }
    }