Playerprefs saving player data in xml file, the functions works for my other android phone except for my one redmi phone?
Redmi 4a which has been updated to android version 6 the function saves player exp and other stats such as attack, health ,etc a test build that was testing this function whether it will save and load the data when player exits and relaunch the app. this function works on my other test device which holds two different version of android, one is version 5 and the other is version 8 the application is built for android version between 5 to the highest version.
GameManager Code //saveAllCharacters public void SaveAllCharacters() { for (int i = 0; i < Character.Length; i++) { SaveManager.instanceSM.SaveCharacter(Character[i].gameObject); } }
//loadAllCharacters
public void LoadAllCharacters() {
for (int i = 0; i < Character.Length; i++)
{
SaveManager.instanceSM.LoadCharacter(Character[i].gameObject);
}
}
save Manager //save Character public void SaveCharacter(GameObject Character) { //temp stats holder cStat = new CharacterStat();
//Character Stats
cs = Character.GetComponent<CharacterStatus>();
//moving stats to temp
cStat.health = cs.health;
cStat.maxHealth = cs.maxHealth;
cStat.maxHealthUpgrade = cs.maxHealthUpgrade;
cStat.upgradeNHealth = cs.upgradeNHealth;
cStat.attack = cs.attack;
cStat.maxAttack = cs.maxAttack;
cStat.upgradeNAttack = cs.upgradeNAttack;
cStat.defence = cs.defence;
cStat.maxDefence = cs.maxDefence;
cStat.upgradeNDefence = cs.upgradeNDefence;
cStat.exp = cs.exp;
cStat.maxExp = cs.maxExp;
cStat.lvl = cs.lvl;
cStat.maxLvl = cs.maxLvl;
cStat.isOwned = cs.isOwned;
//saving it playerPrefs with charater name
PlayerPrefs.SetString(Character.gameObject.name,Helper.Serialize<CharacterStat>(cStat));
}
//Load Character
public void LoadCharacter(GameObject Character) {
//character Stats
cs = Character.GetComponent<CharacterStatus>();
if (PlayerPrefs.HasKey(Character.gameObject.name))
{
//moving character stats from playerPrefs to temp holder
cStat = Helper.Deserialize<CharacterStat(PlayerPrefs.GetString(Character.gameObject.name));
//moving temp stats to character stats
cs.health = cStat.health;
cs.maxHealth = cStat.maxHealth;
cs.maxHealthUpgrade = cStat.maxHealthUpgrade;
cs.upgradeNHealth = cStat.upgradeNHealth;
cs.attack = cStat.attack;
cs.maxAttack = cStat.maxAttack;
cs.upgradeNAttack = cStat.upgradeNAttack;
cs.defence = cStat.defence;
cs.maxDefence = cStat.maxDefence;
cs.upgradeNDefence = cStat.upgradeNDefence;
cs.exp = cStat.exp;
cs.maxExp = cStat.maxExp;
cs.lvl = cStat.lvl;
cs.maxLvl = cStat.maxLvl;
cs.isOwned = cStat.isOwned;
}
else
{
cStat = new CharacterStat();
SaveCharacter(Character);
}
}
*Note ignore spelling error, the has been edited to be post here
Thank you ^^