How to rename a property without losing its inspector value?

I recently learned that I can expose my auto-property’s back field by using this attribute:

[field: SerializeField]
public string MyProperty {get; set;}

But now I cannot use [FormerlySerializedAs] atrribute to rename my property like this:

[field: FormerlySerializedAs("MyProperty")]
pulic string MyNewProperty {get; set;}

Because the backing field’s name is auto-generated to something like:


Is there any good way for me to re-name my auto-property without having to manually type up the backing-field name?

Not sure if this is what you wanted but try

[field: FormerlySerializedAs("<**PreviousPropertyName**>k__BackingField")]

So essentially you just need to wrap it in <> and add k__BackingField