private void OnDestroy() { _luaOnTermination?.Invoke(); _luaOnInitialization = null; _luaOnPreparatory = null; _luaOnRefresh = null; _luaOnRefreshSecond = null; _luaOnTermination = null; _loader.Dispose(); _loader = null; _luaTable.Dispose(); _luaTable = null; _luaEnv = null; }
private void Awake() { DontDestroyOnLoad(gameObject); Current = this; Type type = ReflectionToolkit.GetTypeInRunTimeAssemblies(XHotfixLoaderType); if (type != null) { if (type.IsSubclassOf(typeof(XHotfixLoaderBase))) { _loader = Activator.CreateInstance(type) as XHotfixLoaderBase; } else { Log.Error("创建XLua加载器失败:XLua加载器类 " + XHotfixLoaderType + " 必须继承至加载器基类:XHotfixLoaderBase!"); } } else { Log.Error("创建XLua加载器失败:丢失XLua加载器类 " + XHotfixLoaderType + "!"); } _luaEnv = new LuaEnv(); _luaEnv.AddLoader(_loader.OnLoadRequire); _luaTable = _luaEnv.NewTable(); LuaTable meta = _luaEnv.NewTable(); meta.Set("__index", _luaEnv.Global); _luaTable.SetMetaTable(meta); meta.Dispose(); if (Main.m_Resource.LoadMode == ResourceLoadMode.Resource) { Log.Error("热更新初始化失败:热更新代码不支持使用Resource加载模式!"); return; } }