- Home /
Saving system best approach
Hello guys , I would like to make a saving system for a new game I made so far I have a main menu with a play and a quit buttons , another menu with the buttons level 1 and level 2 and 2 other scenes which are respectively level 1 and level 2 scenes So in one of the tutorials i watched we saved the high score by using :
-using System.Collections;
-//if we have a value that is stored on the computer it will load it as the high score if (PlayerPrefs.HasKey("highscore")) highscorecounter = PlayerPrefs.GetFloat ("highscore");
-if (scorecounter > highscorecounter) { highscorecounter = scorecounter; //allows to store the highscore into the computer and refered as highscore PlayerPrefs.SetFloat ("highscore", highscorecounter);
so the thing is the player gets the main meny he presses play then he gets the levels menu and it should start with level 1 available and level 2 unlocked then when he wins level 1 , level 2 is unlocked (he will directly get redirected to it ) or if he decide to quit the game then play it later he can either choose level 1 or level 2 from the level choice menu
so i thought that i could have a static bool array that will be loaded in all scenes bool playable[0] = true then the level is playable playable[1] = false then the level is not playable once the player wins level 1 we will set playable[1] to true
so in short i would do the following :
1- add using System.Collections; 2- declare a static bool [] playable; 3-set bool[0] playable to true; 4- in level's one winning function : public void win() { Destroy (gameObject); Animator winning = youwon.GetComponent (); winning.SetTrigger ("show"); thegamemanager.restartthegame (); } instead of thegamemanager.restartthegame (); type bool[1] = true ; PlayerPrefs.SetBool ("islevel2playable",bool[1] );
is it a good approach toward this saving system or is there a better approach to it? thank you in advance guys! :)
Your answer
Follow this Question
Related Questions
Life System need help please!!! 1 Answer
PlayerPrefs file wrong stored location 0 Answers
Data formats for android builds 0 Answers
Unity Custom Editor - save value 1 Answer
How to save color 3 Answers