Example #1
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            RequiredField field = attribute as RequiredField;

            if (property.objectReferenceValue == null)
            {
                GUI.color = field.color;
                EditorGUI.PropertyField(position, property, label);
                GUI.color = Color.white;
            }
            else
            {
                EditorGUI.PropertyField(position, property, label);
            }
        }
Example #2
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            RequiredField field = attribute as RequiredField;

            if (property.objectReferenceValue)
            {
                EditorGUI.PropertyField(position, property, label);
                return;
            }

            if (field.debugError)
            {
                Debug.LogErrorFormat(property.serializedObject.targetObject,
                                     "Required field <color=red>{0}</color> is not assigned on <color=blue>{1}</color>!", label.text,
                                     property.serializedObject.targetObject);
            }

            GUI.color = field.color;
            EditorGUI.PropertyField(position, property, label);
            GUI.color = Color.white;
        }