-
Notifications
You must be signed in to change notification settings - Fork 142
Redundant SerializeField attribute
Matt Ellis edited this page Jun 10, 2018
·
7 revisions
If a field has both [SerializeField] and [NonSerialized] attributes, the [NonSeralized] attribute takes precedence and Unity will ignore the [SerializeField] attribute.
This inspection will highlight the [SerializeField] attribute as redundant if both attributes are specified. Starting in Rider/ReSharper 2018.2, this inspection will also mark the [SerializeField] attribute if it is applied to a field that isn't serialised, such as a field in a non-Unity derived class, or if the field is static or readonly.
This inspection also provides an Alt+Enter quick fix to remove the redundant attribute.
See also the Unity documentation on SerializeField.