Cannot work after built but work perfectly fine in editor

Easy Save 2 has been replaced by Easy Save 3, so is no longer supported.
Locked
ariefkyd
Posts: 2
Joined: Fri Oct 19, 2018 3:00 am

Cannot work after built but work perfectly fine in editor

Post by ariefkyd »

Hi,

i got a problem, im new with es2, so what i did was trying to save and load with es2 and built it on android platform, its perfectly work on editor. but when i built, it cant save. and i read the es2 readme it said i've to changed my setting permision on player setting. ive done it but still wont work.

oh yeah im using unity
ariefkyd
Posts: 2
Joined: Fri Oct 19, 2018 3:00 am

Re: Cannot work after built but work perfectly fine in edito

Post by ariefkyd »

public void LoadSaveData(){

#region LOAD ALL DATA
//Total Coin Collect
if (ES2.Exists("TotalCoinCollect" )){
_coinCollected = ES2.Load<float>("TotalCoinCollect");
_coinEarned.text = _coinCollected.ToString();
}
else {
ES2.Save<float>(_coinCollected,"TotalCoinCollect");
}

//Roll achievement
if (ES2.Exists("RollerAchievement"))
{
_nextRoll = ES2.Load<int>("RollerAchievement");
}
else {
ES2.Save<int>(_nextRoll, "RollerAchievement");
}

//stage Unlock
if (ES2.Exists ("BusSim_StageUnlocked")) {
_stageUnlocked = ES2.Load<int> ("BusSim_StageUnlocked");
} else {
_stageUnlocked = 1;
ES2.Save<int> (_stageUnlocked, "BusSim_StageUnlocked");
}

if (ES2.Exists("BusSim_AchieveUnlocked"))
{
_achieveUnlocked = ES2.Load<int>("BusSim_AchievementUnlocked");
}
else {
_achieveUnlocked = 3;
ES2.Save<int>(_achieveUnlocked, "BusSim_AchievementUnlocked");
}

_StageDataList = new List<StageData> ();
for (int i = 0; i < MaxStage; i++) {
StageData sd = new StageData();
if (ES2.Exists ("BusSim_Stage_isUnlocked_"+i.ToString("00"))) {
sd._isUnlocked = ES2.Load<bool> ("BusSim_Stage_isUnlocked_"+i.ToString("00"));
sd._starCount = ES2.Load<int> ("BusSim_Stage_StarUnlocked_"+i.ToString("00"));
sd._bestTime = ES2.Load<int> ("BusSim_Stage_BestTime_"+i.ToString("00"));
sd._unlocked = ES2.Load<int>("BusSim_Stage_Unlocked_" + i.ToString("00"));

//Debug.Log("load "+i +" " + sd._isUnlocked);
//Debug.Log("star " + i + " " + sd._starCount);

}
else {
if (i == 0) {
sd._isUnlocked = true;
sd._unlocked = 1;
} else {
sd._isUnlocked = false;
}
sd._starCount = 0;
sd._bestTime = 0;

ES2.Save<bool> (sd._isUnlocked, "BusSim_Stage_isUnlocked_"+i.ToString("00"));
ES2.Save<int> (sd._starCount, "BusSim_Stage_StarUnlocked_"+i.ToString("00"));
ES2.Save<int> (sd._bestTime, "BusSim_Stage_BestTime_"+i.ToString("00"));
ES2.Save<int>(sd._unlocked,"BusSim_Stage_Unlocked_" + i.ToString("00"));


}
_StageDataList.Add (sd);
}






//Debug.Log(_stageUnlocked);
_AchievementList = new List<AchievementData>();
for (int i = 0; i < MaxAchievement; i++)
{
AchievementData ad = new AchievementData();
if (ES2.Exists("BusSim_Achievement_isUnlocked_" + i.ToString("00")))
{
ad._isUnlocked = ES2.Load<bool>("BusSim_Achievement_isUnlocked_" + i.ToString("00"));
ad._goal = ES2.Load<float>("BusSim_Achievement_Goal_" + i.ToString("00"));
ad._progress = ES2.Load<float>("BusSim_Achievement_Progress_" + i.ToString("00"));
//Debug.Log("load "+i +" " + sd._isUnlocked);

}
else
{
if (i < 3)
{
ad._isUnlocked = true;
}
else
{
ad._isUnlocked = false;
}
ad._goal = JsonReader._instance._achievementData._goal;
ad._progress = 0;
//Debug.Log(JsonReader._instance._achievementData._goal);

ES2.Save<bool>(ad._isUnlocked, "BusSim_Achievement_isUnlocked_" + i.ToString("00"));
ES2.Save<float>(ad._goal, "BusSim_Achievement_Goal_" + i.ToString("00"));
ES2.Save<float>(ad._progress, "BusSim_Achievement_Progress_" + i.ToString("00"));
}
_AchievementList.Add(ad);
}
#endregion

UIStageSelect.Instances.UpdateContent();
UIAchievement.Instance.UpdateAchContent();

}




what the UIStageSelect and UIAchievement does was read the saved file and update their data
that was my code, ive set save/load setting as playerprefs, and player setting to external(sd card).
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Cannot work after built but work perfectly fine in edito

Post by Joel »

Hi there,

Please could you check the console output to check whether errors are occurring at runtime and where? If Easy Save has failed to save or load, it will throw an exception to the console.

Also you may want to try deleting your save data in the Editor and see if this causes the same issue to occur in the Editor. You can do this by going to Assets > Easy Save 2 > Tools and pressing Clear Default Save Folder and Clear PlayerPrefs.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Locked