Dictionary lose it's value after refactor/rename the "field" name.
eg.
from:
[SerializeField] private Dictionary<NpcType, GameObject> a;
rename to (by Rider refactor):
[SerializeField] private Dictionary<NpcType, GameObject> b;
after this, the values stored in the inspector were fully lost.
Which means if that we want to use the inspector as the database, we're in danger.
- Odin Version: 2.0.15
- Unity Version: 2018.3.6f1 Personal
Hope this could be fixed soon.
Comments (5)
-
reporter -
reporter - edited description
-
reporter Well, seem this asset is no longer maintained.
-
I think this behaviour is normal. After renaming a serialized field, you should use the attribute FormerlySerializedAs in order to keep the existing serialization data which points to the former field name. In your case it should be:
[SerializeField] private Dictionary<NpcType, GameObject> a;
[SerializeField] [FormerlySerializedAs("a")] private Dictionary<NpcType, GameObject> b;
-
- changed status to resolved
As Nicolas says, this is indeed expected behaviour, and not a bug. If you rename the field and provide no extra information such as a FormerlySerializedAs attribute, we have no way of knowing that the dictionary should now go into the 'b' field.
- Log in to comment
The "Rename" works well in other variable types, currently, Dictionary is the only type which will lose the values in inspector after rename.