Hi!
I need to save data such as inventory info, level and stuffs like these. I tried to save them into the Assets folder as txt file, but this doesn’t work during runtime (I already read the premade files from the Assets folder, but i cannot Update them). I was thinking about regedit, but I would like to avoid using it.
How can I solve my problem?
Thanks for the reply, bye.
Lets say you played your game and got to lvl 10
You would want to save the variable Lvl 10 and load it some other time.
You can do this by doing PlayerPrefs
var Lvl = 10;
//How we are going to save your level
function SaveLevel ()
{
PlayerPrefs.SetInt("SavedLevel",Lvl);
//We now stored the Lvl variable and saved it as "SavedLevel"
}
//When you press the launch button you want to execute this function.
//Here we are getting the information we stored earlier and then inserting it into the Lvl variable
function LoadLevel ()
{
Lvl = PlayerPrefs.GetInt("SavedLevel");
}
I wrote this code in here and this is not tested, but this is just to show you how you can do it, if you want to go more in depth i suggest you read about PlayerPrefs here
Again this is not for copy paste but merely so you understand the way to do it, atleast a very simple way.