Code inspection: Redundant attribute usage (redundant 'FormerlySerializedAs' attribute)
The [FormerlySerializedAs] attribute is used to tell Unity that a field has been previously serialized with a different name, to allow for versioning and renaming code.
This inspection will highlight redundant usages of the attribute, and provides a quick fix to remove the redundant attribute. The attribute usage is considered redundant if:
It is applied to a field that is not serialized. This can be because the field is declared in a non-Unity type (e.g. does not derive from
MonoBehaviour) or because the field is not serialized (e.g.privateor marked with[NonSerialized]).The previous name specified in the attribute arguments is the same as the current name of the field. E.g.:
// Marked as redundant as the names are the same [FormerlySerializedAs("position")] public int position;
See the documentation for FormerlySerializedAsAttribute and also the Unity blog post announcing the feature.