public void Save() { SetDefaultPath(); TopicJsonObj topicJsonObj = new TopicJsonObj(); topicJsonObj.m_lTopicInfo = new List <TopicInfo>(m_lTopicInfo); Debug.Log("saving ___ total topic info = " + topicJsonObj.m_lTopicInfo.Count); string json = JsonUtility.ToJson(topicJsonObj); Debug.Log(json); if (json.Length > 0) { File.WriteAllText(TOPIC_DB_RAW_PATH, json); } }
public void Load() { SetDefaultPath(); m_lTopicInfo.Clear(); TextAsset txtAsset = Resources.Load <TextAsset>(TOPIC_DB_RESOURCE_PATH); if (txtAsset) { TopicJsonObj topicJsonObj = JsonUtility.FromJson <TopicJsonObj>(txtAsset.text); if (topicJsonObj != null) { m_lTopicInfo = topicJsonObj.m_lTopicInfo; Debug.Log("Loaded ___ raw TOPIC info ___" + m_lTopicInfo.Count); } } }
// ================================== PRIVATE FUNCS ================================== #region Private Funcs private void LoadData() { string textPath = AssetPathConstant.FILE_RAW_DB_SCENE; TextAsset textAsset = Resources.Load <TextAsset>(textPath); // load scene info if (textAsset) { SceneJsonObj sceneJsonObj = JsonUtility.FromJson <SceneJsonObj>(textAsset.text); foreach (SceneInfo sceneInfo in sceneJsonObj.m_lSceneInfo) { m_dSceneInfo.Add(sceneInfo.m_Type, sceneInfo); } } // load hud info textPath = AssetPathConstant.FILE_RAW_DB_HUD; textAsset = Resources.Load <TextAsset>(textPath); if (textAsset) { HUDJsonObj hudJsonObj = JsonUtility.FromJson <HUDJsonObj>(textAsset.text); foreach (HUDInfo HUDInfo in hudJsonObj.m_lHUDInfo) { m_dHUDInfo.Add(HUDInfo.m_HUDType, HUDInfo); } } // load topic info textPath = AssetPathConstant.FILE_RAW_DB_TOPIC; textAsset = Resources.Load <TextAsset>(textPath); if (textAsset) { TopicJsonObj topicJsonObj = JsonUtility.FromJson <TopicJsonObj>(textAsset.text); m_lTopicInfos = new List <TopicInfo>(topicJsonObj.m_lTopicInfo); } // load voca info textPath = AssetPathConstant.FILE_RAW_DB_VOCA; textAsset = Resources.Load <TextAsset>(textPath); if (textAsset) { VocasJsonObj vocasJsonObj = JsonUtility.FromJson <VocasJsonObj>(textAsset.text); foreach (VocasInfo vocasInfo in vocasJsonObj.m_lVocasInfo) { m_dVocaInfos.Add(vocasInfo.m_TopicIndex, vocasInfo); } } // load keyboard info textPath = AssetPathConstant.FILE_RAW_DB_KEYBOARD_TEMPLATE; textAsset = Resources.Load <TextAsset>(textPath); if (textAsset) { KbJsonObj kbJsonObj = JsonUtility.FromJson <KbJsonObj>(textAsset.text); for (int i = 0; i < kbJsonObj.m_lKbTemplate.Count; i++) { KbTemplateInfo kbInfo = kbJsonObj.m_lKbTemplate[i]; for (int j = 0; j < kbInfo.m_lKbTemplate.Count; j++) { string kbForm = kbInfo.m_lKbTemplate[j]; int[,] aKb = DecodeKbTemplate(kbForm); if (j == 0) { List <int[, ]> lKb = new List <int[, ]>(); lKb.Add(aKb); m_dKbTemplate.Add(kbInfo.m_VocaLength, lKb); } else { m_dKbTemplate[kbInfo.m_VocaLength].Add(aKb); } } } } // load map textPath = AssetPathConstant.FILE_RAW_DB_MAP; textAsset = Resources.Load <TextAsset>(textPath); if (textAsset) { MapJsonObj mapJsonObj = JsonUtility.FromJson <MapJsonObj>(textAsset.text); foreach (var mapInfo in mapJsonObj.m_lMapInfo) { m_dMap.Add(mapInfo.m_TopicIndex, mapInfo); } } // load fish textPath = AssetPathConstant.FILE_RAW_DB_FISHES; textAsset = Resources.Load <TextAsset>(textPath); if (textAsset) { FishJsonObj fishJsonObj = JsonUtility.FromJson <FishJsonObj>(textAsset.text); foreach (var fishInfo in fishJsonObj.m_lFishDataInfo) { m_DictFishInfo.Add(fishInfo.m_FishID, fishInfo); } } }