public static void SaveStoreInfo(List <StoreInfo> newinfo) { StoreCfgNormal newCfg = new StoreCfgNormal(); newCfg.Stores = newinfo; string info = JsonUtility.ToJson(newCfg); string persistPath = Application.persistentDataPath + "/Config/StoreCfg.txt"; Utility.CreateDir(persistPath); File.WriteAllText(persistPath, info); LoadStoreInfo(); }
private static void LoadStoreInfo() { string persistPath = Application.persistentDataPath + "/Config/StoreCfg.txt"; if (File.Exists(persistPath)) { string info = File.ReadAllText(persistPath); StoreCfgNormal storeCfgNormal = JsonUtility.FromJson <StoreCfgNormal>(info); foreach (var s in storeCfgNormal.Stores) { StoreInfosDict[s.StoreID] = s; } } else { StoreCfg storeCfg = Resources.Load <StoreCfg>("Configs/StoreCfg"); foreach (var s in storeCfg.Stores) { StoreInfosDict[s.StoreID] = s; } } }