internal static void Reload() { GameObject _go = xLuaRuntime.Singleton.gameObject; xLuaRuntime.Singleton.m_luaEnv.DoString("__lua_runtime__.Cleanup()"); GameObject.Destroy(xLuaRuntime.Singleton); xLuaRuntime.Singleton = null; _go.AddComponent <xLuaRuntime>(); //Init(xLuaRuntime.ms_launchFile); }
// Start is called before the first frame update void Start() { Debug.Assert(Singleton == null); Singleton = this; DontDestroyOnLoad(this.gameObject); m_luaEnv = new XLua.LuaEnv(); m_luaEnv.AddLoader(xLuaLoader.LoadFromResource); m_luaEnv.Global.Set("launch_file", ms_launchFile); m_luaEnv.DoString(Resources.Load <TextAsset>("runtime").text, "runtime"); }
private void OnDestroy() { if (m_luaEnv != null) { m_luaEnv.DoString("__lua_runtime__.Cleanup()"); m_luaEnv.Dispose(); } m_luaEnv = null; if (Singleton == this) { Singleton = null; } }