Serializing a field#


Mark your variable with a [SerializeField] attribute:

[SerializeField] private float _value;

or make it public:

public float Value;

A static, const, or readonly field cannot be serialized.


Unity doesn't serialize properties. You can serialize the backing field of an auto-property using [field: SerializeField]. Versions before 2020 the names did not display appropriately in the Inspector.

[field: SerializeField]
public float Value { get; private set; }

The property must have a set accessor, and cannot be static.

Reasons to avoid serializing compiler-generated backing fields#

My variable is still not appearing in the inspector.