| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 | using System;using System.Collections;using System.Reflection;using UnityEngine;using GFGGame.Launcher;namespace GFGGame{    public class HotUpdateCodeLoader : SingletonMonoBase<HotUpdateCodeLoader>    {        public Type[] allTypes;        public Type[] GetTypes()        {            return this.allTypes;        }        public void StartLoad()        {            StartCoroutine(StartLoadAssemblyHotfix());        }        IEnumerator StartLoadAssemblyHotfix()        {            LogServerHelperHttp.SendNodeLog((int)LogNode.StartLoadGameDll);            //ET.Log.Debug("ILRuntimeLauncher StartLoadAssemblyHotfix");            yield return new WaitForSeconds(0.1f);            var dllPath = $"{LauncherConfig.DllDirHotfix}Game.HotUpdate.dll.bytes";            var asset = GFGAsset.Load<TextAsset>(dllPath);            byte[] assBytes = asset.bytes;            var pdbPath = $"{LauncherConfig.DllDirHotfix}Game.HotUpdate.pdb.bytes";            asset = GFGAsset.Load<TextAsset>(pdbPath);            byte[] pdbBytes = asset.bytes;            StartCoroutine(LoadAssemblyJustInTime(assBytes, pdbBytes));            GFGAsset.Release(dllPath);            GFGAsset.Release(pdbPath);        }        IEnumerator LoadAssemblyJustInTime(byte[] assBytes, byte[] pdbBytes)        {            //mono模式            var assembly = Assembly.Load(assBytes, pdbBytes);            this.allTypes = assembly.GetTypes();            System.Type type = assembly.GetType("GFGGame.HotUpdate.HotUpdateEntry");            type.GetMethod("Start").Invoke(type, null);            yield break;        }    }}
 |