- Home /
playerprefs multiple save slots
Hi there i am kind of new to unity and playerprefs ect.
I need to have 3 seprate save slots for my game that just holds basic details such as how many deaths, current level, time played, pretty basic stuff. I have my data being saved and loaded currently and its working fine, my question is how would i go about having 3 save slots that save and load separately at the start of the game on the menu screen?
Thanks for the help in advance.
Answer by SahanD · Dec 03, 2018 at 01:02 PM
Save
PlayerPrefs.SetInt("deaths", Your Value);
PlayerPrefs.SetInt("currentlevel", Your Value);
PlayerPrefs.SetFloat("timeplayed", Your Value);
Load
int death = PlayerPrefs.SetInt("deaths");
int current_level = PlayerPrefs.SetInt("currentlevel");
float time_played = PlayerPrefs.GetFloat("timeplayed");
Answer by Vega4Life · Dec 02, 2018 at 07:13 PM
Just add a suffix to the saved data indicating the slot.
int slot = 1; // Or whatever slot they picked
PlayerPrefs.SetInt ("CurrentLevel_" + slot), CurrentLevel);
Your answer
Follow this Question
Related Questions
Saving and load from player prefs in Unity3D on mobile devices?? 0 Answers
Problems with Playerprefs script 1 Answer
Saving Scenes and loading GameObjects? 4 Answers
How to efficiently hand out rewards based on the level that the player completed? 3 Answers
Saving & Loading the scene (or at least one array) via Javascript 1 Answer