static void CheckLuaDictValid() { if (mLuaDict.Count > 0) { return; } TextAsset textAsset = Resources.Load <TextAsset>("index") as TextAsset; byte[] buffer = (textAsset != null) ? textAsset.bytes : null; int offset = 0; while (offset < buffer.Length) { LuaIndexData indexData = new LuaIndexData(); indexData.offset = ReadInt(buffer, ref offset); indexData.size = ReadInt(buffer, ref offset); string key = ReadString(buffer, ref offset); if (mLuaDict.ContainsKey(key)) { Debugger.LogError("==== Reapeat Lua File is " + key + " =====!!!"); mLuaDict[key] = indexData; } else { mLuaDict.Add(key, indexData); } } }
public static byte[] GetLuaBytes(ref string filePath) { GetFilePathKey(ref filePath); CheckLuaDictValid(); LuaIndexData indexData = null; if (mLuaDict.TryGetValue(filePath, out indexData) == false) { return(null); } Debugger.Log(string.Format("==== Custom GetLuaFile Success {0} ====", filePath)); if (indexData.bytes != null) { return(indexData.bytes); } CheckLuaContentValid(); indexData.bytes = new byte[indexData.size]; Array.Copy(contentBytes, indexData.offset, indexData.bytes, 0, indexData.size); return(indexData.bytes); }