Hello,
**I am using JavaScript**
I Would like to know if i should (at the end of each level) have a script that looks like this:
function OnCollisionEnter () {
//CHECK Last loaded level
}
if (loaded level == 1) {
PlayerPrefs.SetInt("LevelOneData", 1);
//Using a Seperate script for this, this is a function in that script gotten from PreviewLabs
//that is supposed to be faster than unity's Save(); function! See Question for details*
PlayerPrefs.Flush();
}
if (loaded level == 2) {
PlayerPrefs.SetInt("LevelTwoData", 1);
//Using a Seperate script for this, this is a function in that script gotten from PreviewLabs
//that is supposed to be faster than unity's Save(); function! See Question for details*
PlayerPrefs.Flush();
}
if (loaded level == 3) {
PlayerPrefs.SetInt("LevelThreeData", 1);
//Using a Seperate script for this, this is a function in that script gotten from PreviewLabs
//that is supposed to be faster than unity's Save(); function! See Question for details*
PlayerPrefs.Flush();
}
//IMAGINE 150 more of these...
OR is this going to RESAVE every and ALL Player prefs? Which obviously if i had 50 of them that would be serious lag)
SIDE NOTE: **However i found this company that made this excellent script to help reduce lag for iOS! [PreviewLabs][1]**
Or should i have a different script for Each level to ENSURE it only saves that ONE playerPref? Like this:
//OR should i do this, This would be attached to the finish line collider, there would be one
//for each level and the only thing that
//would change is the name of the script and the
//"LevelOneData" to say "LevelTwoData" ect...
function OnCollisionEnter () {
PlayerPrefs.SetInt("LevelOneData", 1);
}
My two questions when i thought of this was:
1. Will the One big script Save ALL the player prefs every time? Or will it only save the one that changed, If it saves them all at once WITH the Knowledge of Me using that Script ([PreviewLabs][2]) thats supposed to SPEED up the saving Process, Would the LARGE script be okay to use?
2. Does it make a difference WHERE i put the .Flush(); or .Save();? It saves ALL the variables in all player pref scripts correct? Is there away around this or does there even need to be?
Thanks for your help!
I know this is a tough question, Thats why i need help :P
Daniel
[1]: http://www.previewlabs.com/writing-playerprefs-fast/
[2]: http://www.previewlabs.com/writing-playerprefs-fast/
↧