Custom naming settings for private serialized field

 Working in Unity, I like to use private fields with [SerializeField] attribute.

But I want to distinguish them from standard private fields. So I'm using a _UpperCamelCase with the underscore in front, because in some way they are accessible from the editor as they were public.

Now I have to add a resharper comment around these fields in all my classes. Would be nice to have an additional option in the Editor > Code Style > C# > Naming tab for serialized field.

1 comment
Comment actions Permalink

I think this is a bad naming practice.

In addition, Unity has other ways to serialize an object, and it's not clear how the Rider should handle them. For example, you can use Odin serialization, or your type may not have the attribute [Serializable], but be a serializable exception (Vector2, Vector3, Matrix4x4, Quaternion, etc. have this principle). Your field can be serialized and remain private (without using [SerializeField]), for example, if you are working inside EditorWindow. Perhaps any class inside EditorWindow will internally follow the same logic. And it is not obvious now whether the private field is serializable, since the context of using the type is not always obvious.

The worst thing is that Rider is bound to standard serialization in this case.


Please sign in to leave a comment.