/// <summary> /// 主线程回调 /// </summary> /// <param name="ev"></param> private static void MainRunAction(object ev) { TheardEvent cache = (TheardEvent)ev; try { if (cache.action == null) { DebugMod.Log("theard action is null" + cache.name); } cache.action(); } catch { DebugMod.LogError("run thunder cathch" + cache.name); } finally { if (cache.callback != null) { cache.callback(); } Interlocked.Decrement(ref m_iRunThreadsNum); } }
public void OnInit(string text = null) { m_Data = text; m_Buttons = new Dictionary <string, LuaFunction>(); InitAssetBundle(); InitLua(); DebugMod.Log("OnInit---->>>" + name + " text:>" + text); }
protected void OnDestroy() { if (m_Bundle != null) { m_Bundle.Release(); } if (LuaScriptMgr.Instance != null) { LuaScriptMgr.Instance.SafeRelease(ref m_AwakeFunc); LuaScriptMgr.Instance.SafeRelease(ref m_UpdateFunc); LuaScriptMgr.Instance.SafeRelease(ref m_LateUpdateFunc); LuaScriptMgr.Instance.SafeRelease(ref m_FixedUpdateFunc); LuaScriptMgr.Instance.SafeRelease(ref m_LevelLoaded); LuaScriptMgr.Instance.LuaGC(); } DebugMod.Log("~" + name + "was destory!"); }
/// <summary> /// 启动更新下载,这里只是个思路演示,此处可启动线程下载更新 /// </summary> IEnumerator OnUpdateResource() { m_DownloadFiles.Clear(); m_CurDownloadNum = 0; if (!AppConst.UpdateMode) { OnResourceInited(); yield break; } string dataPath = PathMod.DataPath; //数据目录 string url = AppConst.WebUrl; //string random = DateTime.Now.ToString("yyyymmddhhmmss"); string listUrl = url + "files.txt";//?v=" + random; Debug.LogWarning("LoadUpdate---->>>" + listUrl); //下载文件列表 WWW www = new WWW(listUrl); yield return(www); if (www.error != null) { OnUpdateFailed(string.Empty); yield break; } if (!Directory.Exists(dataPath)) { Directory.CreateDirectory(dataPath); } File.WriteAllBytes(dataPath + "files.txt", www.bytes); string filesText = www.text; string[] files = filesText.Split('\n'); string ver = ""; if (files.Length > 0) { ver = files[0]; } string message = string.Empty; for (int i = 0; i < files.Length; i++) { if (string.IsNullOrEmpty(files[i])) { continue; } string[] keyValue = files[i].Split('|'); string f = keyValue[0]; string localfile = (dataPath + f).Trim(); string path = Path.GetDirectoryName(localfile); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string fileUrl = url + keyValue[0];// + "?v=" + random; bool canUpdate = !File.Exists(localfile); //如果文件存在 md5不一样就重新下载 if (!canUpdate) { string remoteMd5 = keyValue[1].Trim(); string localMd5 = Util.md5file(localfile); canUpdate = !remoteMd5.Equals(localMd5); if (canUpdate) { File.Delete(localfile); } } //本地缺少文件 if (canUpdate) { DebugMod.Log(fileUrl); message = "downloading>>" + fileUrl; //这里都是资源文件,用线程下载 while (m_CurDownloadNum > m_MaxDownloadNum) { yield return(new WaitForEndOfFrame()); } BeginDownload(fileUrl, localfile); //检查下载文件列表 while (!(IsDownOK(localfile))) { yield return(new WaitForEndOfFrame()); } } } yield return(new WaitForEndOfFrame()); message = "更新完成!!"; //facade.SendMessageCommand(NotiConst.UPDATE_MESSAGE, message); //GameMain.GlobalObject.SendMessage("OnShowMessage", message); //AssetManager.Instance.Initialize(OnResourceInited); OnResourceInited(); }