Ejemplo n.º 1
0
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            float height = base.GetPropertyHeight(property, label);

            try
            {
                var sdpTokenAttr = attribute as SdpTokenAttribute;
                SdpTokenAttribute.Validate(property.stringValue, sdpTokenAttr.AllowEmpty);
            }
            catch (ArgumentException)
            {
                // Add extra space for the error message
                height += c_errorMessageHeight;
            }
            return(height);
        }
Ejemplo n.º 2
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            try
            {
                var sdpTokenAttr = attribute as SdpTokenAttribute;
                SdpTokenAttribute.Validate(property.stringValue, sdpTokenAttr.AllowEmpty);
            }
            catch (ArgumentException)
            {
                // Display error message below the property
                var totalHeight = position.height;
                position.yMin = position.yMax - c_errorMessageHeight;
                EditorGUI.HelpBox(position, "Invalid characters in property. SDP tokens cannot contain some characters like space or quote. See SdpTokenAttribute.Validate() for details.", MessageType.Error);

                // Adjust rect for the property itself
                position.yMin  = position.yMax - totalHeight;
                position.yMax -= c_errorMessageHeight;
            }

            EditorGUI.PropertyField(position, property, label);
        }