public bool Load(string packName, string tabName) { PacketRouting packetRouting = PacketManage.Single.GetPacket(packName); if (packetRouting == null) { return(false); } byte[] byteFile = packetRouting.LoadBytes(tabName); if (byteFile == null) { return(false); } int byteStartIndex = 0; if (byteFile.Length >= 3) { if (byteFile[0] == 0xEF && byteFile[1] == 0xBB && byteFile[2] == 0xBF) { byteStartIndex = 3;//跳过utf8文件头 } } m_Tab.Deserialization(byteFile, byteStartIndex, byteFile.Length - byteStartIndex); return(true); }
//Dictionary<Shader, Dictionary<Texture, Dictionary<Color, Material>>> m_Mats = new Dictionary<Shader, Dictionary<Texture, Dictionary<Color, Material>>>(); public MFAModel GetModel(string packName, string modelName) { /* * if (!m_Models.ContainsKey(packName)) * { * //装载包 * if (!m_NeedLoadPacks.Contains(packName)) * { * m_NeedLoadPacks.Add(packName); * AutoStartLoadCo(); * } * return null; * }*/ if (!m_Models.ContainsKey(packName)) { m_Models.Add(packName, new Dictionary <string, MFAModel>()); ResourceRefManage.Single.AddRef(packName); } Dictionary <string, MFAModel> models = m_Models[packName]; if (!models.ContainsKey(modelName)) { PacketRouting pack = PacketManage.Single.GetPacket(packName); if (pack == null) { Debug.LogError(string.Format("YQ2ModelManage 无法装载包 {0}", packName)); } byte[] modelData = pack.LoadBytes(modelName + ".bytes"); if (modelData == null) { return(null); } MFAModel new_model = new MFAModel(); using (MemoryStream stream = new MemoryStream(modelData)) { new_model.Deserialize(stream); } //YQ2Model new_model = new YQ2Model( pack.Load(modelName) as GameObject); models.Add(modelName, new_model); return(new_model); } return(models[modelName]); }
static int LoadBytes(IntPtr L) { try { ToLua.CheckArgsCount(L, 3); PacketRouting obj = (PacketRouting)ToLua.CheckObject(L, 1, typeof(PacketRouting)); string arg0 = ToLua.CheckString(L, 2); FileSystem.RES_LOCATION arg1 = (FileSystem.RES_LOCATION)ToLua.CheckObject(L, 3, typeof(FileSystem.RES_LOCATION)); byte[] o = obj.LoadBytes(arg0, arg1); ToLua.Push(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }