saving unlocked characters?

Let’s say I have several characters at first which is locked. The player can then purchase any additional characters throughout the game.

How to make the game saving the unlocked characters each time the player run the game? I’m thinking of using playerPrefs but I can’t figure out how to make it possible.

There are multiple ways of doing this. There is no universal solution, every game is different but there are some methods you can try out. For instance create a database inside of unity with all of the possible characters and give each one a uniqueID. Then you can keep a List of the characters that the player has unlocked, each item in the list will correspond to the uniqueID you made in unity. Then you can set up system where they can choose a player from their currently unlocked list. You can save this data in a .txt file (I don’t recommend), XML (I recommend but encrypt the data), JSON (I recommend but encrypt the data), SQLite (I recommend but encrypt the data sine SQLite does not have a key), .bin, .dat, .whateverYouWant. Using unique endings will require some serialization on your part. Or read the bytes and reinterpret them. I do this a lot in C++ when writing classes to files using reinterpret_cast and reading them too. So again there is no one answer it just depends on your understanding of I/O and how complicated you want to make things. I do not recommend using PlayerPrefs as the data is not encrypted. Someone could easily access the file and edit the data. If you encrypt the data it is viable. For instance, save everything as a string, the keys can also be encrypted and the data you save (whatever it may be) should reinterpreted into a byte[ ] and sent into a string then encrypted and saved. To read it back decrypt it convert it back to byte[ ] and reinterpret it back to its original form. Like I said many different ways.