public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); var showWarning = (property.propertyType == SerializedPropertyType.ObjectReference && property.objectReferenceValue == null); NullFieldGUI.nullCheckedField(position, property, label, showWarning); EditorGUI.EndProperty(); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); var showWarning = ( property.propertyType == SerializedPropertyType.ObjectReference && property.objectReferenceValue == null && FindNonNull.classHasAttributeOfType(property.serializedObject.targetObject.GetType(), typeof(NonNullAttribute)) ); NullFieldGUI.nullCheckedField(position, property, label, showWarning); EditorGUI.EndProperty(); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); bool showWarning; switch (property.propertyType) { case SerializedPropertyType.String: showWarning = string.IsNullOrEmpty(property.stringValue); break; case SerializedPropertyType.AnimationCurve: showWarning = (property.animationCurveValue == null || property.animationCurveValue.length == 0); break; case SerializedPropertyType.LayerMask: showWarning = (property.intValue == 0); break; case SerializedPropertyType.ArraySize: showWarning = (property.arraySize == 0); break; case SerializedPropertyType.Color: showWarning = (property.colorValue == null || property.colorValue == new Color(0, 0, 0, 0)); break; case SerializedPropertyType.Enum: showWarning = (property.enumValueIndex == 0); break; case SerializedPropertyType.Integer: showWarning = (property.intValue == 0); break; case SerializedPropertyType.Float: showWarning = (Mathf.Approximately((float)property.doubleValue, 0)); break; case SerializedPropertyType.Vector2: showWarning = property.vector2Value == Vector2.zero; break; case SerializedPropertyType.Vector3: showWarning = property.vector3Value == Vector3.zero; break; // case SerializedPropertyType.Vector4: showWarning = property.vector4Value == Vector4.zero; break; case SerializedPropertyType.Vector2Int: showWarning = property.vector2IntValue == Vector2Int.zero; break; case SerializedPropertyType.Vector3Int: showWarning = property.vector3IntValue == Vector3Int.zero; break; default: showWarning = false; break; } NullFieldGUI.nullCheckedField(position, property, label, showWarning); EditorGUI.EndProperty(); }