Question by
cyberland_ct · Jul 10, 2018 at 05:46 PM ·
save dataipad
Application.persistentDataPath+"/playerinfo.dat" not saving in ipad but working in editor
I have this save function to save the file and load function to load it. I followed the tutorial https://unity3d.com/learn/tutorials/topics/scripting/persistence-saving-and-loading-data.
The code works in the editor and android devices but when build to ipad it does not work
public void Save(){
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Create(Application.persistentDataPath+"/playerinfo.dat");
PlayerData data = new PlayerData();
data.starscore=starscore;
data.language=language;
data.unlockLearn = unlockLearn;
data.unlockPlay = unlockPlay;
data.unlockChallenge = unlockChallenge;
data.rateApp = rateApp;
data.autoplay = autoplay;
data.elephantscore=elephantscore;
data.lionscore=lionscore;
data.pandascore=pandascore;
data.tigerscore=tigerscore;
data.level2=level2;
data.level3=level3;
data.level4=level4;
data.level5=level5;
data.level6=level6;
data.level7=level7;
data.level8=level8;
data.xtrablock=xtrablock;
data.screentimer=screentimer;
data.savedtimermin=savedtimermin;
data.countdown=countdown;
data.savedtimerhr=savedtimerhr;
data.sec = sec;
data.min = min;
data.hrs = hrs;
data.locked=locked;
data.firstplay=firstplay;
bf.Serialize(file,data);
file.Close();
}
public void Load(){
if(File.Exists(Application.persistentDataPath+"/playerinfo.dat")){
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Open(Application.persistentDataPath+"/playerinfo.dat", FileMode.Open);
PlayerData data = (PlayerData)bf.Deserialize(file);
file.Close();
starscore = data.starscore;
language = data.language;
unlockLearn = data.unlockLearn;
unlockPlay = data.unlockPlay;
unlockChallenge = data.unlockChallenge;
rateApp = data.rateApp;
autoplay = data.autoplay;
elephantscore=data.elephantscore;
lionscore=data.lionscore;
pandascore=data.pandascore;
tigerscore=data.tigerscore;
level2=data.level2;
level3=data.level3;
level4=data.level4;
level5=data.level5;
level6=data.level6;
level7=data.level7;
level8=data.level8;
xtrablock=data.xtrablock;
screentimer=data.screentimer;
savedtimermin=data.savedtimermin;
countdown=data.countdown;
savedtimerhr = data.savedtimerhr;
sec = data.sec;
min = data.min;
hrs = data.hrs;
locked = data.locked;
firstplay = data.firstplay;
}
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612170436im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
garbage collection in between scene changes? 2 Answers
iOS Device Screen UI Resolution 1 Answer
Saving In Between Scenes and Program Exit 0 Answers
Change Savedata without errors 0 Answers