public static void Init(IResLoad resLoad = null) { if (appdomain != null) { return; } #if UNITY_EDITOR DllInitByEditor.Release(); #endif if (resLoad == null) { #if UNITY_EDITOR ResLoad.Set(new EditorResLoad()); #endif } else { ResLoad.Set(resLoad); } InitHotModule(); refType = new RefType("hot.hotApp"); refType.TryInvokeMethod("Init"); AllTypes = new List <IType>(); foreach (var ator in appdomain.LoadedTypes) { AllTypes.Add(ator.Value); } AutoReplace(AllTypes); InitByProperty(typeof(AutoInitAndRelease), "Init", AllTypes); }
// 释放所有热更模块 public static void ReleaseAll() { if (appdomain == null) { return; } ResLoad.Set(null); refType.TryInvokeMethod("ReleaseAll"); //var types = new Dictionary<string, IType>(appdomain.LoadedTypes); InitByProperty(typeof(AutoInitAndRelease), "Release", AllTypes); foreach (var ator in Fields) { ator.SetValue(null, null); } Fields.Clear(); IL.Help.ReleaseAll(); AllTypes.Clear(); AllTypes = null; refType = null; appdomain = null; System.GC.Collect(); }
// 释放所有热更模块 public static void ReleaseAll() { if (appdomain == null) { return; } ResLoad.Set(null); refType.TryInvokeMethod("ReleaseAll"); //var types = new Dictionary<string, IType>(appdomain.LoadedTypes); InitByProperty(typeof(AutoInitAndRelease), "Release", AllTypes); foreach (var ator in Fields) { ator.SetValue(null, null); } Fields.Clear(); // 释放CLR绑定,类继承等全局变量 { #if UNITY_EDITOR CallStatic("ILRuntime.Runtime.Generated.CLRBindings", "Shutdown", appdomain); CallStatic("wxb.AllAdapter", "Shutdown", appdomain); #else ILRuntime.Runtime.Generated.CLRBindings.Shutdown(appdomain); AllAdapter.Release(); #endif } IL.Help.ReleaseAll(); AllTypes.Clear(); AllTypes = null; refType = null; appdomain = null; if (DllStream != null) { DllStream.Close(); DllStream = null; } #if USE_PDB || USE_MDB if (SymbolStream != null) { SymbolStream.Close(); SymbolStream = null; } #endif System.GC.Collect(); }
public static IEnumerator Init() { if (appdomain != null) { yield break; } yield return(NewInitSceneLoader.Instance.StartCoroutine(InitHotModule())); refType = new RefType("hot.hotApp"); refType.TryInvokeMethod("Init"); AllTypes = new List <IType>(); foreach (var ator in appdomain.LoadedTypes) { AllTypes.Add(ator.Value); } AutoReplace(AllTypes); InitByProperty(typeof(AutoInitAndRelease), "Init", AllTypes); }
public static void Init(IResLoad resLoad = null) { if (appdomain != null) { return; } #if UNITY_EDITOR DllInitByEditor.Release(); #endif if (resLoad == null) { #if UNITY_EDITOR ResLoad.Set(new EditorResLoad()); #endif } else { ResLoad.Set(resLoad); } InitHotModule(); #if HOT_DEBUG if (UnityEngine.Application.isPlaying) { System.Type debugger_type; if (IL.Help.TryGetTypeByFullName("hot.Debugger", out debugger_type)) { var debugger = new RefType(true, debugger_type); object port = debugger.TryGetField("port"); if (port != null) { var ds = appdomain.DebugService; ds.StartDebugService((int)port); object vsWaitTimeoutTime = debugger.TryGetField("vsWaitTimeoutTime"); if (vsWaitTimeoutTime != null) { int wt = (int)vsWaitTimeoutTime; if (wt > 0) { L.Log("vsWait begin!"); int count = 0; while (!ds.IsDebuggerAttached) { System.Threading.Thread.Sleep(1000); ++count; if (count >= wt) { L.Log("vsWait timeout!"); break; } } L.Log("vsWait end!"); } } } } } #endif refType = new RefType("hot.hotApp"); refType.TryInvokeMethod("Init"); AllTypes = new List <IType>(); foreach (var ator in appdomain.LoadedTypes) { AllTypes.Add(ator.Value); } AutoReplace(AllTypes); InitByProperty(typeof(AutoInitAndRelease), "Init", AllTypes); }