예제 #1
0
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            if (buttonAttribute == null)
            {
                buttonAttribute = attribute as EZInspectorButtonAttribute;
            }
            switch (buttonAttribute.layout)
            {
            case EZInspectorButtonAttribute.ButtonLayout.Above:
                return(EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing + base.GetPropertyHeight(property, label));

            case EZInspectorButtonAttribute.ButtonLayout.Replace:
                return(EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing);

            case EZInspectorButtonAttribute.ButtonLayout.Below:
                return(EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing + base.GetPropertyHeight(property, label));

            default:
                return(base.GetPropertyHeight(property, label));
            }
        }
예제 #2
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            if (buttonAttribute == null)
            {
                buttonAttribute = attribute as EZInspectorButtonAttribute;
            }

            EditorGUI.BeginProperty(position, label, property);
            switch (buttonAttribute.layout)
            {
            case EZInspectorButtonAttribute.ButtonLayout.Above:
                position.height = EditorGUIUtility.singleLineHeight;
                DrawButton(position, property.serializedObject.targetObject);
                position.y     += position.height + EditorGUIUtility.standardVerticalSpacing;
                position.height = base.GetPropertyHeight(property, label);
                EditorGUI.PropertyField(position, property);
                break;

            case EZInspectorButtonAttribute.ButtonLayout.Replace:
                DrawButton(position, property.serializedObject.targetObject);
                break;

            case EZInspectorButtonAttribute.ButtonLayout.Below:
                position.height = base.GetPropertyHeight(property, label);
                EditorGUI.PropertyField(position, property);
                position.y     += position.height + EditorGUIUtility.standardVerticalSpacing;
                position.height = EditorGUIUtility.singleLineHeight;
                DrawButton(position, property.serializedObject.targetObject);
                break;

            default:
                EditorGUI.PropertyField(position, property);
                break;
            }
            EditorGUI.EndProperty();
        }