Hi guys, I have a custom class which I need to save individually across 5 characters and 5 different jobs which can be equipped to any character.
[System.Serializable]
public string char;
public string job;
public class Skill{
public bool crush;
public bool parry;
public bool slam;
public bool magic;
public bool evadeUp;
}
public Skill[] allSkills;
Question is, how do I save this class or array?
The following is my previous attempt:
void SaveSkill ()
{
if (char == "FirstChar" job == "Warrior")
{
if (crush == true)
PlayerPrefs.setInt("FirstcharWarriorCrush", 1);
if (parry== true)
PlayerPrefs.setInt("FirstcharWarriorParry", 1);
}
}
Which will require me to cycle through every combination of character and job and skill. About 100 playerprefs…
Go with the JSON approach. It looks like what you’re trying to serialize is pretty simple and my JSON .NET asset is way overkill for what you’re needing to do. You should take a look at JSON Object which is free on the asset store, documented and pretty simple to use for cases like yours: