I am hitting a strange issue with score serialization in my game.
I have a LevelHighScore class:
[System.Serializable]
public class LevelHighScores
{
readonly Dictionary<Level, ModeScores> scores;
// clipped out the rest for simplicity
}
With a enum key, Level
.
I recently added some new levels to my game, but instead of adding the new levels to the end of the enum, I added the new enums in alphabetical order. Now when I load the game my new levels have existing scores associated with them, making me think that the ordinal of the enums are having an effect on the serialization / deserialization.
I want to avoid to avoid this issue when adding levels in the future. I also don't want to have to remember to only add levels to the end of the enum.
Is there a way to ensure that enum are deserialized consistently, even when retroactively adding new values?