// ============================================================================================= // Save public void Save() { List <int> costs = new List <int>(); List <bool> purchased = new List <bool>(); List <int> tiers = new List <int>(); foreach (Toggle toggle in toggles) { costs.Add(toggle.GetComponent <SkillTreeButton>().cost); purchased.Add(toggle.GetComponent <SkillTreeButton>().purchased); tiers.Add(toggle.GetComponent <SkillTreeButton>().tier); } SaveObject saveObject = new SaveObject { unlockedTier = unlockedTier, NumUnlockedT1 = NumUnlockedT1, NumUnlockedT2 = NumUnlockedT2, NumUnlockedT3 = NumUnlockedT3, NumUllockedT4 = NumUNlockedT4, NumT1ToUnlockT2 = NumT1ToUnlockT2, NumT2ToUnlockT3 = NumT2ToUnlockT3, NumT3ToUnlockT4 = NumT3ToUnlockT4, costs = costs, purchased = purchased, tiers = tiers, }; string json = JsonUtility.ToJson(saveObject); SaveSkillTree.Save(json); }
// Load public void Load() { string saveString = SaveSkillTree.Load(); SaveObject saveObject = JsonUtility.FromJson <SaveObject>(saveString); unlockedTier = saveObject.unlockedTier; NumUnlockedT1 = saveObject.NumUnlockedT1; NumUnlockedT2 = saveObject.NumUnlockedT2; NumUnlockedT3 = saveObject.NumUnlockedT3; NumUNlockedT4 = saveObject.NumUllockedT4; NumT1ToUnlockT2 = saveObject.NumT1ToUnlockT2; NumT2ToUnlockT3 = saveObject.NumT2ToUnlockT3; NumT3ToUnlockT4 = saveObject.NumT3ToUnlockT4; for (int i = 0; i < toggles.Count; i++) { toggles[i].GetComponent <SkillTreeButton>().cost = saveObject.costs[i]; toggles[i].GetComponent <SkillTreeButton>().purchased = saveObject.purchased[i]; toggles[i].GetComponent <SkillTreeButton>().tier = saveObject.tiers[i]; } }
public void SaveSnapshot() { snapshot = menu.skillTree.GetSnapshot(); }
public void SaveSnapshot () { snapshot = menu.skillTree.GetSnapshot(); }