void CheckFile(string fileName) { string path = Application.dataPath + "/Resources/Json/" + fileName + ".json"; #if (UNITY_EDITOR) path = Application.dataPath + "/Resources/Json/" + fileName + ".json"; #elif (UNITY_STANDALONE_WIN) path = Application.dataPath + "/StreamingAssets/Json/" + fileName + ".json"; #elif (UNITY_ANDROID) string sDirPath; sDirPath = Application.persistentDataPath + "/Json"; DirectoryInfo di = new DirectoryInfo(sDirPath); if (di.Exists == false) { di.Create(); } path = Application.persistentDataPath + "/Json/" + fileName + ".json"; #endif FileInfo fi = new FileInfo(path); if (fi.Exists) { if (fileName == "PlayerStatus") { playerStatus = LoadJsonFile <PlayerStatus>("PlayerStatus"); playerStatusModel.CharacterStatus = playerStatus; } else if (fileName == "Schedule") { gameSchedule = LoadJsonFile <GameSchedule>("Schedule"); for (int i = 0; i < gameSchedule.alonGameShedule.Length; i++) { listAlongGameSchedule.Add(gameSchedule.alonGameShedule[i]); dicSchedule.Add(i, gameSchedule.alonGameShedule[i]); } scheduleModel.DicSchedule = dicSchedule; } else if (fileName == "PlayerInventory") { playerInventory = LoadJsonFile <PlayerInventory>("PlayerInventory"); playerInventoryModel.PlayerInventory = playerInventory; } else if (fileName == "HoloStarSetting") { holostarSetting = LoadJsonFile <HoloStarSetting>("HoloStarSetting"); holostarSettingModel.HoloStarSetting = holostarSetting; } else if (fileName == "Calendar") { calanderEvent = LoadJsonFile <CalanderEvent>("Calendar"); calendarModel.AlarmEvents = calanderEvent.alarmEvents.ToList(); } } else { if (fileName == "PlayerStatus") { CreatePlayerStatus(); playerStatusModel.CharacterStatus = playerStatus; } else if (fileName == "Schedule") { CreateScheduleJson(); for (int i = 0; i < listAlongGameSchedule.Count; i++) { dicSchedule.Add(i, listAlongGameSchedule[i]); } scheduleModel.DicSchedule = dicSchedule; } else if (fileName == "PlayerInventory") { CreatePlayerInventoryJson(); playerInventoryModel.PlayerInventory = playerInventory; } else if (fileName == "HoloStarSetting") { CreateSettingJson(); holostarSettingModel.HoloStarSetting = holostarSetting; } } }
void CheckFile(string fileName) { #if (UNITY_EDITOR) string path = Application.dataPath + "/Resources/Json/" + fileName + ".json"; #elif (UNITY_ANDROID) string sDirPath; sDirPath = Application.persistentDataPath + "/Json"; DirectoryInfo di = new DirectoryInfo(sDirPath); if (di.Exists == false) { di.Create(); } string path = Application.persistentDataPath + "/Json/" + fileName + ".json"; #endif FileInfo fi = new FileInfo(path); if (fi.Exists) { if (fileName == "PlayerStatus") { playerStatus = LoadJsonFile <PlayerStatus>("PlayerStatus"); playerStatusModel.CharacterStatus = playerStatus; } else if (fileName == "Schedule") { gameSchedule = LoadJsonFile <GameSchedule>("Schedule"); for (int i = 0; i < gameSchedule.alonGameShedule.Length; i++) { listAlongGameSchedule.Add(gameSchedule.alonGameShedule[i]); dicSchedule.Add(i, gameSchedule.alonGameShedule[i]); } scheduleModel.DicSchedule = dicSchedule; } else if (fileName == "PlayerInventory") { playerInventory = LoadJsonFile <PlayerInventory>("PlayerInventory"); playerInventoryModel.PlayerInventory = playerInventory; playerInventoryModel.ArrayBuyCharacter = playerInventory.buyCharacter; playerInventoryModel.ArrayBuySkinNum = playerInventory.buySkinNum; } else if (fileName == "HoloStarSetting") { holostarSetting = LoadJsonFile <HoloStarSetting>("HoloStarSetting"); holostarSettingModel.HoloStarSetting = holostarSetting; } else if (fileName == "MobileOption") { mobileOption = LoadJsonFile <MobileOption>("MobileOption"); mobileOptionModel.MobileOption = mobileOption; } } else { if (fileName == "PlayerStatus") { CreatePlayerStatus(); playerStatusModel.CharacterStatus = playerStatus; } else if (fileName == "Schedule") { CreateScheduleJson(); for (int i = 0; i < listAlongGameSchedule.Count; i++) { dicSchedule.Add(i, listAlongGameSchedule[i]); } scheduleModel.DicSchedule = dicSchedule; } else if (fileName == "PlayerInventory") { CreatePlayerInventoryJson(); playerInventoryModel.PlayerInventory = playerInventory; playerInventoryModel.ArrayBuyCharacter = playerInventory.buyCharacter; playerInventoryModel.ArrayBuySkinNum = playerInventory.buySkinNum; } else if (fileName == "HoloStarSetting") { CreateSettingJson(); holostarSettingModel.HoloStarSetting = holostarSetting; } else if (fileName == "MobileOption") { CreateMobileOptionJson(); mobileOptionModel.MobileOption = mobileOption; } } }