private void load(string name) { #if false // for debug texts = new string[10]; for (int i = 0; i < texts.GetLength(0); i++) { texts[i] = "text" + i; } #else // 真实逻辑 TextAsset ta; MemoryStream fs = null; BinaryReader br = null; try { ta = (TextAsset)Resources.Load(XLDictionaryMgr.DICTIONARY_PATH + name); fs = new MemoryStream(ta.bytes); br = new BinaryReader(fs); int textCount = br.ReadInt32(); _texts = new string[textCount]; for (int i = 0; i < _texts.GetLength(0); i++) { _texts[i] = XLStreamTools.readJavaUTF(br); } } catch (Exception ex) { Debug.Log(ex); } finally { if (br != null) { br.Close(); } if (fs != null) { fs.Close(); } } #endif }
/// <summary> /// 构造 /// </summary> private XLDictionaryMgr() { // 真实逻辑 TextAsset ta; MemoryStream fs = null; BinaryReader br = null; try { ta = (TextAsset)Resources.Load(XLDictionaryMgr.DICTIONARY_PATH + "DictionaryMgr"); fs = new MemoryStream(ta.bytes); br = new BinaryReader(fs); _dictionaryCount = br.ReadInt32(); _dictionaryNames = new string[_dictionaryCount]; _dictionarys = new XLDictionary[_dictionaryCount]; for (int i = 0; i < _dictionaryCount; i++) { _dictionaryNames[i] = XLStreamTools.readJavaUTF(br); } } catch (Exception ex) { Debug.Log(ex); } finally { if (br != null) { br.Close(); } if (fs != null) { fs.Close(); } } }