public List <T> LoadCSVNoCache <T>(ResourceID resID) where T : CSVBaseData { UnityEngine.Object resourceObj = ResourceManager.Instance.GetResource(resID); if (resourceObj == null) { return(null); } string csvText = ""; TextAsset csvTextAsset = UnityEngine.Object.Instantiate(resourceObj) as TextAsset; byte[] csv_bs; #if ENABLE_ENCRYPTION ResDecryption.Decryption(csvTextAsset.bytes, out csv_bs); #else csv_bs = csvTextAsset.bytes; #endif csvText = Encoding.UTF8.GetString(csv_bs); if (string.IsNullOrEmpty(csvText)) { return(null); } return(ParseCSV <T>(csvText)); }
public void LoadCSV <T>(string tableName) where T : CSVBaseData { string typeKey = GetDataListsKey <T>(); if (m_ConfigDataLists.ContainsKey(typeKey)) { Debug.LogWarning("duplicated key in config: " + typeKey); return; } string csvText = ""; TextAsset csvTextAsset = Resources.Load <TextAsset>("CSV/" + tableName); Debugger.Log("table name=" + tableName); byte[] csv_bs; #if ENABLE_ENCRYPTION ResDecryption.Decryption(csvTextAsset.bytes, out csv_bs); #else csv_bs = csvTextAsset.bytes; #endif csvText = Encoding.UTF8.GetString(csv_bs); if (string.IsNullOrEmpty(csvText)) { return; } List <T> result = ParseCSV <T>(csvText); if (result != null) { List <CSVBaseData> list = new List <CSVBaseData>(); for (int i = 0; i < result.Count; i++) { CSVBaseData item = result[i]; list.Add(item); string pKey = item.GetPrimaryKey(); if (string.IsNullOrEmpty(pKey) == false) { string itemKey = GetDataItemKey <T>(pKey); if (m_ConfigDataItemss.ContainsKey(itemKey) == false) { m_ConfigDataItemss.Add(itemKey, item); } else { Debug.Log("duplicate item key: " + itemKey); } } } m_ConfigDataLists.Add(typeKey, list); } }