static public int getABDataWritePath_s(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); if (matchType(l, argc, 1, typeof(string), typeof(string))) { System.String a1; checkType(l, 1, out a1); System.String a2; checkType(l, 2, out a2); var ret = XLoad.getABDataWritePath(a1, a2); pushValue(l, true); pushValue(l, ret); return(2); } else if (matchType(l, argc, 1, typeof(string), typeof(bool))) { System.String a1; checkType(l, 1, out a1); System.Boolean a2; checkType(l, 2, out a2); var ret = XLoad.getABDataWritePath(a1, a2); pushValue(l, true); pushValue(l, ret); return(2); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function getABDataWritePath to call"); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int load_s(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); if (matchType(l, argc, 1, typeof(List <System.String>), typeof(System.Action <XLoadDesc>))) { System.Collections.Generic.List <System.String> a1; checkType(l, 1, out a1); System.Action <XLoadDesc> a2; LuaDelegation.checkDelegate(l, 2, out a2); var ret = XLoad.load(a1, a2); pushValue(l, true); pushValue(l, ret); return(2); } else if (matchType(l, argc, 1, typeof(List <XLoadRes>), typeof(System.Action <XLoadDesc>))) { System.Collections.Generic.List <XLoadRes> a1; checkType(l, 1, out a1); System.Action <XLoadDesc> a2; LuaDelegation.checkDelegate(l, 2, out a2); var ret = XLoad.load(a1, a2); pushValue(l, true); pushValue(l, ret); return(2); } else if (matchType(l, argc, 1, typeof(string), typeof(System.Action <XLoadDesc>))) { System.String a1; checkType(l, 1, out a1); System.Action <XLoadDesc> a2; LuaDelegation.checkDelegate(l, 2, out a2); var ret = XLoad.load(a1, a2); pushValue(l, true); pushValue(l, ret); return(2); } else if (argc == 3) { System.String a1; checkType(l, 1, out a1); System.Type a2; checkType(l, 2, out a2); System.Action <XLoadDesc> a3; LuaDelegation.checkDelegate(l, 3, out a3); var ret = XLoad.load(a1, a2, a3); pushValue(l, true); pushValue(l, ret); return(2); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function load to call"); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int get_isReinstall(IntPtr l) { try { XLoad self = (XLoad)checkSelf(l); pushValue(l, true); pushValue(l, self.isReinstall); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int Update(IntPtr l) { try { XLoad self = (XLoad)checkSelf(l); self.Update(); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int init(IntPtr l) { try { XLoad self = (XLoad)checkSelf(l); var ret = self.init(); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } }
public XLoadDesc loadLua(Action <XLoadDesc> cb = null) { string path = "Assets/Res/lua/"; #if (UNITY_STANDALONE_WIN && UNITY_EDITOR) // 肯定是forceLoadAB if (!XConf.forceLoadAB) { path = "lua"; } #endif return(XLoad.loadAll(path, typeof(TextAsset), cb)); }
static public int set__fixInfo(IntPtr l) { try { XLoad self = (XLoad)checkSelf(l); XPackInfo v; checkType(l, 2, out v); self._fixInfo = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int set_assets(IntPtr l) { try { XLoad self = (XLoad)checkSelf(l); System.Collections.Generic.Dictionary <XAssetKey, XAssetInfo> v; checkType(l, 2, out v); self.assets = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int fillDesc(IntPtr l) { try { XLoad self = (XLoad)checkSelf(l); XLoadDesc a1; checkType(l, 2, out a1); var ret = self.fillDesc(a1); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int getAssetInfo(IntPtr l) { try { XLoad self = (XLoad)checkSelf(l); XLoadRes a1; checkType(l, 2, out a1); var ret = self.getAssetInfo(a1); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int unloadAssetInfoFromCache(IntPtr l) { try { XLoad self = (XLoad)checkSelf(l); XAssetKey a1; checkValueType(l, 2, out a1); var ret = self.unloadAssetInfoFromCache(a1); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int realLoad(IntPtr l) { try { XLoad self = (XLoad)checkSelf(l); System.Collections.Generic.List <XLoadRes> a1; checkType(l, 2, out a1); System.Action <XLoadDesc> a2; LuaDelegation.checkDelegate(l, 3, out a2); var ret = self.realLoad(a1, a2); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int loadAll_s(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); if (argc == 2) { System.String a1; checkType(l, 1, out a1); System.Action <XLoadDesc> a2; LuaDelegation.checkDelegate(l, 2, out a2); var ret = XLoad.loadAll(a1, a2); pushValue(l, true); pushValue(l, ret); return(2); } else if (argc == 3) { System.String a1; checkType(l, 1, out a1); System.Type a2; checkType(l, 2, out a2); System.Action <XLoadDesc> a3; LuaDelegation.checkDelegate(l, 3, out a3); var ret = XLoad.loadAll(a1, a2, a3); pushValue(l, true); pushValue(l, ret); return(2); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function loadAll to call"); return(2); } catch (Exception e) { return(error(l, e)); } }
// XApp 启动 IEnumerator init() { XDebug.Log("init:" + Time.realtimeSinceStartup); // 先启动装载服务器 yield return(StartCoroutine(XLoad.instance.init())); if (!XLoad.instance.isOK) { // 弹对话框 XDebug.LogError("致命错误XLoad没有装载成功"); } else { // 先加载进度条 XLoadDesc desc = XLoad.load("Assets/Res/progress/style1.prefab"); yield return(desc); if (desc.ob == null) { XDebug.LogError("Assets/Res/progress/style1.prefab not exist, quit!!!"); yield break; } XDebug.Log("onLoadProgress:" + Time.realtimeSinceStartup); xloading = this.gameObject.AddComponent <XLoading>(); xpool = this.gameObject.AddComponent <XPoolManager>(); GameObject loadingStyle0 = GameObject.Instantiate(desc.ob, uiProgress) as GameObject; xloading.addStyle(0, loadingStyle0, loadingStyle0.transform.Find("Slider").GetComponent <UnityEngine.UI.Slider>(), null, loadingStyle0.transform.Find("Info").GetComponent <UnityEngine.UI.Text>(), null); // 切换进度条 XLoading.instance.beginShow(0); bool wantUpdateVersion = XConf.isUpdateVersion; // 是否更新 if (!XLoad.instance.isLoadFromAB) { // editor状态下并不更新版本 wantUpdateVersion = false; } if (wantUpdateVersion) { // 创建更新对象 XUpdate xup = new XUpdate(); // 开启更新协程 yield return(StartCoroutine(xup.updateVersion(XConf.publishUrl))); if (xup.isFail) { // 失败了MSGBOX,重新更新,下载链接?都是从头走,清除已装载的东西 yield break; } else { // 成功了,那么走正式流程,再次来一发 // 清理操作------- // StartCoroutine(init()); // yield break; } } XLoadDesc descBack = XLoad.load("Assets/Res/ui/uiBack.prefab"); XLoading.instance.beginShow(0, descBack); yield return(descBack); if (descBack.ob != null) { GameObject.Instantiate(descBack.ob, this.uiBack); } #region 装载lua // 开始装载lua文件 XLoadDesc descLua = loadLua(); XLoading.instance.beginShow(0, descLua); yield return(descLua); var luaAsInfo = descLua.assetInfo; if (luaAsInfo.isSuccess) { luaDict = descLua.obDict; } // 装载lua函数 LuaState.loaderDelegate += loadLuaFile; // 创建一个luaSvr luaSvr = new LuaSvr(); luaSvr.init(); XLuaBind luaBind = new XLuaBind { luaSvr = luaSvr }; XLoading.instance.beginShow(0, luaBind); // 全局装载函数 // 绑定的时间 yield return(luaBind); // 绑定完成后从Main开始执行 luaSvr.onBindComplete(() => { // 初始化调试器 ldb = new DebugInterface(luaSvr.luaState); ldb.init(); XDebug.Log("luaBindComplete start Main" + Time.realtimeSinceStartup); luaSvr.start(XConf.luastart); XDebug.Log("luaBindComplete end Main" + Time.realtimeSinceStartup); }); #endregion } }
public string getUpdateDirName() { return(XLoad.getABDataWritePath("/" + oldver + "to" + newver + "/")); }
// 更新流程 public IEnumerator updateVersion(string publishUrl) { // 转化下平台接口 publishUrl = getPlatformPublishUrl(publishUrl); // 切换进度条 XLoading.instance.beginShow(0, this); string urlver = XUtil.getUrl(publishUrl, "ver.json"); WWW wwwver = new WWW(urlver); _www = wwwver; _wwwinfo = "获取" + urlver + "中"; yield return(wwwver); XVer ver = new XVer(); if (!string.IsNullOrEmpty(wwwver.error) || !ver.load(wwwver.text)) { XDebug.LogError("远程版本文件" + urlver + wwwver.error); wwwver.Dispose(); _www = null; _status = XUpdateStatus.FAIL; yield break; } wwwver.Dispose(); XDebug.Log("更新开始远程版本号:v" + ver.ver + "当前版本号:v" + XLoad.instance.localver); if (ver.ver != XLoad.instance.localver) { string urlversion = XUtil.getUrl(ver.ab, "v" + ver.ver + "/assets/version.json"); WWW wwwWebInfo = new WWW(urlversion); _www = wwwWebInfo; _wwwinfo = "获取" + urlversion + "中"; yield return(wwwWebInfo); XPackInfo webInfo = new XPackInfo(); if (!string.IsNullOrEmpty(wwwWebInfo.error) || !webInfo.load(wwwWebInfo.text)) { XDebug.LogError("远程版本文件" + urlver + wwwWebInfo.error); wwwWebInfo.Dispose(); _www = null; _status = XUpdateStatus.FAIL; yield break; } wwwWebInfo.Dispose(); Dictionary <string, XBundleInfo> modify = XLoad.instance._info.compareWebList(webInfo); uint allsize = 0; int filecount = modify.Count; foreach (var bd in modify) { allsize += (uint)(bd.Value.fileSize); } if (filecount <= 0) { XDebug.Log("文件一样无需更新修改版本号"); XLoad.instance._info._version = ver.ver; // 保存文件 XLoad.instance._info.saveFile(XLoad.getABDataWritePath("assets/version.json")); _status = XUpdateStatus.SUCESS; // todo 修改版本号 yield break; } XDebug.Log(string.Format("一共{0}个文件,大小需要更新{1}", filecount, XUtil.getSizeString(allsize))); // 更新目录 this.oldver = XLoad.instance.localver; this.newver = ver.ver; string updateDirName = getUpdateDirName(); string updateFileName = getUpdateFileName("update.json"); if (XUtil.isExistDirectory(updateDirName) && XUtil.isExistFile(updateFileName)) { if (!loadFile(updateFileName)) { alreadyDownloadDict.Clear(); XUtil.clearDirectory(updateDirName); } } int fileno = 0; foreach (var bd in modify) { fileno++; string ufilename = getUpdateFileName(bd.Key, bd.Value.isDirectory); if (alreadyDownloadDict.ContainsKey(bd.Key)) { XBundleInfo bundleInfo = alreadyDownloadDict[bd.Key]; if (bundleInfo.fileSize == bd.Value.fileSize && bundleInfo.hash == bd.Value.hash && XUtil.isExistFile(ufilename)) { XDebug.Log("文件已下载完毕,跳过" + ufilename); continue; } } if (XUtil.isExistFile(ufilename)) { XUtil.deleteFile(ufilename); } string webufile = getUpdateWebName(ver.ab, "v" + ver.ver + "/" + bd.Key, bd.Value.isDirectory); WWW wwwufile = new WWW(webufile); _www = wwwufile; _wwwinfo = string.Format("下载({0}/{1}){2}", fileno, filecount, bd.Key); yield return(wwwufile); if (!string.IsNullOrEmpty(wwwufile.error)) { XDebug.LogError("远程文件" + webufile + wwwufile.error); wwwufile.Dispose(); _www = null; _status = XUpdateStatus.FAIL; yield break; } if (!XUtil.writeFileAllBytes(ufilename, wwwufile.bytes)) { XDebug.LogError("写入文件失败" + ufilename); wwwufile.Dispose(); _www = null; _status = XUpdateStatus.FAIL; yield break; } alreadyDownloadDict[bd.Key] = bd.Value; // 保存一下记录 saveFile(updateFileName); wwwufile.Dispose(); _www = null; } // 已经成功了,拷贝文件到目标文件 _wwwinfo = "拷贝文件中"; foreach (var bd in modify) { string ufilename = getUpdateFileName(bd.Key, bd.Value.isDirectory); string dfilename = XLoad.getABDataWritePath(bd.Key, bd.Value.isDirectory); if (!XUtil.copyFile(ufilename, dfilename)) { XDebug.LogError("拷贝文件失败" + ufilename); _status = XUpdateStatus.FAIL; break; } XLoad.instance._info.addBundle(bd.Key, bd.Value); } _wwwinfo = "重新生成版本文件"; XLoad.instance._info.callDependAllSize(); // 变更版本 XLoad.instance._info._version = ver.ver; // 保存文件 if (!XLoad.instance._info.saveFile(XLoad.getABDataWritePath("assets/version.json"))) { _status = XUpdateStatus.FAIL; yield break; } _status = XUpdateStatus.SUCESS; } else { // XDebug.Log("版本一致没有什么不同无需更新"); _status = XUpdateStatus.SUCESS; } }