Beispiel #1
0
        /// <summary>
        /// 加载热更新DLL
        /// </summary>
        public async void LoadHotfixDLL()
        {
            AppDomain = new AppDomain();
            ILRuntimeHelper.InitILRuntime(AppDomain);

            TextAsset dllAsset = await GameEntry.Resource.AwaitLoadAsset <TextAsset>(AssetUtility.GetHotfixDLLAsset("Hotfix.dll"));

            byte[] dll = dllAsset.bytes;
            Log.Info("hotfix dll加载完毕");

#if DEBUG && !DISABLE_ILRUNTIME_DEBUG
            TextAsset pdbAsset = await GameEntry.Resource.AwaitLoadAsset <TextAsset>(AssetUtility.GetHotfixDLLAsset("Hotfix.pdb"));

            byte[] pdb = pdbAsset.bytes;
            Log.Info("hotfix pdb加载完毕");

            AppDomain.LoadAssembly(new MemoryStream(dll), new MemoryStream(pdb), new Mono.Cecil.Pdb.PdbReaderProvider());

            //启动调试服务器
            AppDomain.DebugService.StartDebugService(56000);
#else
            AppDomain.LoadAssembly(new MemoryStream(dll));
#endif
            //设置Unity主线程ID 这样就可以用Profiler看性能消耗了
            AppDomain.UnityMainThreadID = System.Threading.Thread.CurrentThread.ManagedThreadId;

            HotfixStart();
        }
Beispiel #2
0
        /// <summary>
        /// 加载热更新DLL
        /// </summary>
        public void LoadHotfixDLL()
        {
            HotfixLoaded = false;

            if (IsILRuntimeMode)
            {
                AppDomain = new AppDomain();
                ILRuntimeUtility.InitILRuntime(AppDomain);

                //启动调试服务器
                AppDomain.DebugService.StartDebugService(56000);
                Log.Info("启动了ILRuntime调试服务器");

                m_LoadAssetCallbacks = new LoadAssetCallbacks(OnLoadHotfixDLLSuccess, OnLoadHotfixDLLFailure);

                GameEntry.Resource.LoadAsset(AssetUtility.GetHotfixDLLAsset("Hotfix.dll"), typeof(TextAsset), m_LoadAssetCallbacks, 1);
                GameEntry.Resource.LoadAsset(AssetUtility.GetHotfixDLLAsset("Hotfix.pdb"), typeof(TextAsset), m_LoadAssetCallbacks, 2);
            }
        }