Hello guys, first thank you for browsing my thread.
I have a question. This question may sound ridiculous.
Because some complex. (for me)
Think of a game and there are levels in the game. There are also questions at these levels.
For example, at level 1 there are 3 questions.
At level 1, we answered our second question incorrectly. The player then quits the game, but I want the player to save the question he was in and answer that question when he comes back.
I would like to record which level and which question lasted.
It’s like recording in registration.
This is a question and answer game.
What I want from you is to explain the logic of this. Because I did not understand anything. At least it could be a video.
All you need to do is save what level and question they were on and then reload the data. Depending on your needs, it could be as simple as a player pref, or an actual save and load system, or saving online. But for simple, just make two playerprefs and have one be a level and one be the question. Then update the level playerpref when they go to a level and as they answer questions, record the last question they were on.
Don’t use the binary formatter/serializer: it is insecure, it cannot be made secure, and it makes debugging very difficult, plus it actually will NOT prevent people from modifying your save data on their computers.
PlayerPrefs should be enough, though if you don’t want casual users going around and editing their save files, BinaryFormatter should be good enough, though slightly more experienced users can break its security.
PlayerPrefs.SetInt("QuestionNumber", /* Question number */);
// Optional because it is automatically called when the application closes
PlayerPrefs.Save();
Loading the question number:
int questionNumber = PlayerPrefs.GetInt("QuestionNumber", /* Value if nothing has been saved, recommended: 0 */);
One point about BinaryFormatter that is not often mentioned is how fragile it is. If you so much as change which interfaces your serialized class implements any serialized data will become incompatible. Not robust whatsoever.