private IEnumerable DoStartGame() { LuaStatic.Load = CustomLoader; LuaStatic.LoadFromAssetsPath = LoadFromAssetsPath; LuaScriptMgr sm = LuaScriptMgr.Instance; yield return(null); foreach (var item in sm.Bind()) { yield return(item); } sm.Start(); yield return(null); try { sm.DoString("require [[init]]"); sm.DoString("require [[preload]]"); } catch (LuaScriptException e) { HobaDebuger.LogErrorFormat("LuaScriptException: {0}", e.Message); yield break; } yield return(null); var luaState = sm.GetLuaState(); if (luaState.L != IntPtr.Zero) { int oldTop = LuaDLL.lua_gettop(luaState.L); do { LuaDLL.lua_getglobal(luaState.L, "preload"); if (LuaDLL.lua_pcall(luaState.L, 0, 1, 0) != 0) { HobaDebuger.LogErrorFormat("LuaScriptException: {0}", LuaDLL.lua_tostring(luaState.L, -1)); yield break; } bool ret = LuaDLL.lua_toboolean(luaState.L, -1); LuaDLL.lua_pop(luaState.L, 1); if (ret) { break; } yield return(null); } while (true); LuaDLL.lua_settop(luaState.L, oldTop); yield return(null); } //设置scale sm.GetDesignWidthAndHeight(ref _DesignWidth, ref _DesignHeight); if (_DesignWidth > 0 && _DesignHeight > 0) { OSUtility.SetDesignContentScale(_DesignWidth, _DesignHeight); } yield return(null); try { if (!_BeForArtTest) { sm.CallLuaFunction("StartGame"); } else { sm.CallLuaFunction("SceneTest"); } _IsInited = true; } catch (LuaScriptException e) { HobaDebuger.LogErrorFormat("LuaScriptException: {0}", e.Message); _IsInited = false; } yield return(null); ReadResPath(); //读取C#端需要的lua路径 StartCoroutine(TickCoroutine().GetEnumerator()); yield return(null); }