Question by
visca_c · May 22, 2021 at 01:36 AM ·
propertyrenameserializefield
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:
"<MyProperty>k__BackingField"
Is there any good way for me to re-name my auto-property without having to manually type up the backing-field name?
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613034033im_/https://answers.unity.com/themes/thub/images/avi.jpg)