You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unity doesn't like readonly fields in serialization, so when a field is marked with the SerializeFieldAttribute, the suggestion to "Field can be made readonly" should be suppressed, since it will cause that field to silently no longer be serialized by Unity.
This only happens in classes that are not Unity based, e.g. not derived from MonoBehaviour. This is because we don't mark any fields, even those with attributes, as implicitly used unless they are in a Unity class.
Behaviour should be:
If the custom class has a [Serializable] attribute, handle all fields as though they're on a MonoBehaviour. I.e. public fields or those marked with [SerializeField] are implicitly used, [NotSerialized] disables this. Highlight the fields as Unity fields (gutter icon)
If a class does not have the [Serializable] attribute, highlight usages of [SerializeField]. I think it should be a redundant highlight - the attribute does nothing, so grey it out. Quick fix to remove, another to add [Serializable] to the class. (Alternatives would be hint or suggestion on the attribute to require [Serializable] on the class, as this is clearly the intention)
Unity doesn't like readonly fields in serialization, so when a field is marked with the
SerializeFieldAttribute
, the suggestion to "Field can be made readonly" should be suppressed, since it will cause that field to silently no longer be serialized by Unity.Related issues #291 and #25
The text was updated successfully, but these errors were encountered: