IEnumerator PreStartCheck()
    {
        if (GLog.IsLogInfoEnabled)
        {
            GLog.LogInfo("PreStartCheck run 0");
        }
        string ready = LuaEvent.TrigClrEvent <string>("SDK_READY_TO_START");

        if (GLog.IsLogInfoEnabled)
        {
            GLog.LogInfo("PreStartCheck run 1");
        }
        if (!string.IsNullOrEmpty(ready))
        {
            if (GLog.IsLogInfoEnabled)
            {
                GLog.LogInfo("PreStartCheck run 2");
            }
            while (ready != "ready")
            {
                yield return(null);

                if (GLog.IsLogInfoEnabled)
                {
                    GLog.LogInfo("PreStartCheck run 3");
                }
                ready = LuaEvent.TrigClrEvent <string>("SDK_READY_TO_START");
            }
        }

#if EFUN_SDK_EN || EFUN_SDK_TW
        // obb
        ResManager.Init();
#endif

        if (GLog.IsLogInfoEnabled)
        {
            GLog.LogInfo("PreStartCheck run 4");
        }
        var workpending = ResManager.MovePendingUpdate(LoadingReport);
        if (workpending != null)
        {
            while (workpending.MoveNext())
            {
                yield return(workpending.Current);

                if (GLog.IsLogInfoEnabled)
                {
                    GLog.LogInfo("PreStartCheck run 5");
                }
            }
        }

#if UNITY_EDITOR && !USE_CLIENT_RES_MANAGER
        ResManager.RecordCacheVersion("editor", int.MaxValue);
#else
        IEnumerator work = null;
        try
        {
            SetLoadingPhaseAmount(3);
            SetLoadingPhase(0);
            work = ResManager.DecompressScriptBundle("default", LoadingReport);
        }
        catch (Exception e)
        {
            if (GLog.IsLogErrorEnabled)
            {
                GLog.LogException(e);
            }
            LoadingReportError();
            yield break;
        }
        if (work != null)
        {
            while (true)
            {
                try
                {
                    if (!work.MoveNext())
                    {
                        break;
                    }
                }
                catch (Exception e)
                {
                    if (GLog.IsLogErrorEnabled)
                    {
                        GLog.LogException(e);
                    }
                    LoadingReportError();
                    yield break;
                }
                yield return(work.Current);
            }
        }
        foreach (var flag in ResManager.GetDistributeFlags())
        {
            try
            {
                //SetLoadingPhase(loadingPhase + 1);
                work = ResManager.DecompressScriptBundle("distribute/" + flag, LoadingReport);
            }
            catch (Exception e)
            {
                if (GLog.IsLogErrorEnabled)
                {
                    GLog.LogException(e);
                }
                LoadingReportError();
                yield break;
            }
            if (work != null)
            {
                while (true)
                {
                    try
                    {
                        if (!work.MoveNext())
                        {
                            break;
                        }
                    }
                    catch (Exception e)
                    {
                        if (GLog.IsLogErrorEnabled)
                        {
                            GLog.LogException(e);
                        }
                        LoadingReportError();
                        yield break;
                    }
                    yield return(work.Current);
                }
            }
        }
        try
        {
            SetLoadingPhase(loadingPhase + 1);
            work = ResManager.UpdateResourceBundleLocalAll(LoadingReport);
        }
        catch (Exception e)
        {
            if (GLog.IsLogErrorEnabled)
            {
                GLog.LogException(e);
            }
            LoadingReportError();
            yield break;
        }
        if (work != null)
        {
            while (true)
            {
                try
                {
                    if (!work.MoveNext())
                    {
                        break;
                    }
                }
                catch (Exception e)
                {
                    if (GLog.IsLogErrorEnabled)
                    {
                        GLog.LogException(e);
                    }
                    LoadingReportError();
                    yield break;
                }
                yield return(work.Current);
            }
        }
        try
        {
            SetLoadingPhase(loadingPhase + 1);
            work = ResManager.SplitResIndexAsyncAll(LoadingReport);
        }
        catch (Exception e)
        {
            if (GLog.IsLogErrorEnabled)
            {
                GLog.LogException(e);
            }
            LoadingReportError();
            yield break;
        }
        if (work != null)
        {
            while (true)
            {
                try
                {
                    if (!work.MoveNext())
                    {
                        break;
                    }
                }
                catch (Exception e)
                {
                    if (GLog.IsLogErrorEnabled)
                    {
                        GLog.LogException(e);
                    }
                    LoadingReportError();
                    yield break;
                }
                yield return(work.Current);
            }
        }
        yield return(new WaitForEndOfFrame());

        if (ResManager.TryGetAssetDesc("Assets/CapstonesRes/Common/Fonts/CapstonesPlaceHolder.otf") != null)
        {
            ResManager.MarkPermanent("Assets/CapstonesRes/Common/Fonts/DistributeFontInfo.fi.txt");
            ResManager.MarkPermanent("Assets/CapstonesRes/Common/Fonts/CapstonesPlaceHolder.otf");
            ResManager.LoadRes("Assets/CapstonesRes/Common/Fonts/DistributeFontInfo.fi.txt");
            ResManager.LoadRes("Assets/CapstonesRes/Common/Fonts/CapstonesPlaceHolder.otf");
        }
#endif

        LoadingReport("WaitForBiReport", null);
        yield return(new WaitForEndOfFrame());

        try
        {
            //ResManager.UnloadAllRes();
            GC.Collect();
            //GC.WaitForPendingFinalizers();
        }
        catch (Exception e)
        {
            if (GLog.IsLogErrorEnabled)
            {
                GLog.LogException(e);
            }
            LoadingReportError();
            yield break;
        }

        //LuaBehaviour.luaEnv.DoString("require 'main'");
        UnityEngine.SceneManagement.SceneManager.LoadScene("DemoEntry");

        yield break;
    }