コード例 #1
0
        /// <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);
            }
        }
コード例 #2
0
        public static void LogException(Exception e, string extMsg, bool showMsgBox)
        {
            try
            {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.AppendFormat("应用程序出现了异常:\r\n{0}\r\n", e.Message);

                stringBuilder.AppendFormat("\r\n 额外信息: {0}", extMsg);
                if (null != e)
                {
                    if (e.InnerException != null)
                    {
                        stringBuilder.AppendFormat("\r\n {0}", e.InnerException.Message);
                    }
                    stringBuilder.AppendFormat("\r\n {0}", e.StackTrace);
                }

                //记录异常日志文件
                //LogManager.WriteException(stringBuilder.ToString());
                if (showMsgBox)
                {
                    //弹出异常日志窗口
                    System.Console.WriteLine(stringBuilder.ToString());
                }
            }
            catch (Exception ex)
            {
                DebugMod.LogException(ex);
            }
        }
コード例 #3
0
ファイル: LuaBehaviour.cs プロジェクト: yuisunn/UnityCrazy
 public void OnInit(string text = null)
 {
     m_Data    = text;
     m_Buttons = new Dictionary <string, LuaFunction>();
     InitAssetBundle();
     InitLua();
     DebugMod.Log("OnInit---->>>" + name + " text:>" + text);
 }
コード例 #4
0
ファイル: ResourceMgr.cs プロジェクト: yuisunn/UnityCrazy
        public static T Load <T>(string path) where T : Object
        {
            if (!Instance.mCacheDic.ContainsKey(path))
            {
                T res = Resources.Load <T>(path);
                if (res == null)
                {
                    DebugMod.LogError("can't find res from " + path);
                    return(null);
                }
                Instance.mCacheDic[path] = new ResCache()
                {
                    resCache = (Object)res
                };
            }

            return(Instance.mCacheDic[path].resCache as T);
        }
コード例 #5
0
        /// <summary>
        /// 格式化堆栈信息
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static void LogFormatStack(System.Diagnostics.StackTrace stackTrace, string extMsg)
        {
            try
            {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.AppendFormat("应用程序出现了对象锁定超时错误:\r\n");

                stringBuilder.AppendFormat("\r\n 额外信息: {0}", extMsg);
                stringBuilder.AppendFormat("\r\n {0}", stackTrace.ToString());

                //记录异常日志文件
                //LogManager.WriteException(stringBuilder.ToString());
            }
            catch (Exception e)
            {
                DebugMod.LogException(e);
            }
        }
コード例 #6
0
ファイル: LuaBehaviour.cs プロジェクト: yuisunn/UnityCrazy
        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!");
        }
コード例 #7
0
        IEnumerator LoadSceneEnumerator(string path, string scenename, VoidDelegate loadfinishdo)
        {
            if (string.IsNullOrEmpty(scenename))
            {
                yield break;
            }

            _www = new WWW(path);
            yield return(_www);

            _sceneBundle = _www.assetBundle;
            _www.Dispose();
            _www = null;

            if (_sceneBundle != null)
            {
                _asyn = Application.LoadLevelAsync(scenename);
                yield return(_asyn);

                if (_asyn.isDone)
                {
                    yield return(1);

                    try
                    {
                        if (loadfinishdo != null)
                        {
                            loadfinishdo();
                        }
                    }
                    catch
                    {
                        DebugMod.LogError("Error occored in LoadSceneEnumerator callback delegate");
                    }


                    _asyn = null;
                }
            }
            else
            {
                DebugMod.LogError("can't load scene from: " + path);
            }
        }
コード例 #8
0
        public static void Trigger <T>(T e) where T : EventArgs
        {
            Delegate del;

            if (Instance.mEventDic.TryGetValue(typeof(T), out del))
            {
                EventDelegate <T> callback = del as EventDelegate <T>;
                try
                {
                    if (callback != null)
                    {
                        callback(e);
                    }
                }
                catch
                {
                    DebugMod.LogError("Event Trigger error on:" + typeof(T).ToString());
                }
            }
        }
コード例 #9
0
ファイル: AssetBundleMgr.cs プロジェクト: yuisunn/UnityCrazy
        public AssetBundle LoadAsset(string path)
        {
            AssetBundle ab = null;

            if (mAssetBundleDic.ContainsKey(path))
            {
                ab = GetAssetBundle(path);
            }
            else
            {
                ab = LoadAssetMemory(path);
                AddAssetBundle(path, ab);
                if (ab == null)
                {
                    DebugMod.LogError("can't get AssetBundle null from " + path);
                }
                //GameMain.Instance.StartCoroutine(LoadBundleEnumerator(path, cb, managercharge));
            }
            return(ab);
        }
コード例 #10
0
ファイル: AssetBundleMgr.cs プロジェクト: yuisunn/UnityCrazy
        /// <summary>
        /// 加载Asset资源
        /// </summary>
        /// <param name="path">StreamingAssets下相对路径</param>
        /// <param name="sourcename">资源名</param>
        /// <param name="cb">回调函数</param>
        /// <returns></returns>
        public Object LoadAsset(string path, string sourcename)
        {
            Object      obj = null;
            AssetBundle ab  = GetAssetBundle(path);

            if (ab != null)
            {
                obj = ab.LoadAsset(sourcename);
            }
            else
            {
                ab = LoadAssetMemory(path);
                AddAssetBundle(path, ab);
                obj = ab.LoadAsset(sourcename);

                if (obj == null)
                {
                    DebugMod.LogError("can't get assetresource object null from " + path);
                }
            }
            return(obj);
        }
コード例 #11
0
ファイル: HotUpdateMgr.cs プロジェクト: yuisunn/UnityCrazy
        /// <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();
        }