Change certain value without modified other values.

Hi guys. I’m sorry if the title is confusing. Full explanation below.

Okay so I have this Serialize Class [LevelData.cs]

And I create a List from different class. [LevelDataManager.cs]
7568110--936889--Screenshot_1.png

This is the SaveGame script. I call it on Awake(). [GameDataManager.cs]

The flow is when player start the game on the first time, SaveGame will save the List and all of its values in txt file.
And when the player load the game, it will load the txt file and put it back in the List.

Let say when player finish playing Level 0, Unlocked and Completed flagged as True and player’s gem will reduce based on GemCost, and added based on GemEarn. So when the player start the game again, Level 0 is marked as Completed so do other values. But the problem is when I want to update the values in the Inspector for example; GemCost = 1 and GemEarn = 3, the game will load the file and replace the value back to 0. The player has to remove the save file and start over the game to get the latest values.

So what I want is, I want to change the GemCost and GemEarn in the Inspector without changing the Unlocked and Completed values in player save file. Is there a way to achieve this and how to do it?

I hope my explanation is understandable. Thank you for your time :slight_smile:

Well, your issue may be inside your SaveGame method which you did not include. Furthermore your code that does create a new List in case the list is null, actually adds all items twice. The List constructor that takes another collection as parameter already fills in the elements from that collection into the list. You then iterate through the whole list again and add all elements once more to the end of the list. So you end up with having all the elements two times in the list.

It’s also not clear where you actually load your saved information.