// Use this for initialization void Start() { SDKMgr.Instance.TrackGameLog("3000", "开始加载lua配置"); LuaTable G = LuaMgr.Instance.GetLuaEnv().Global; UnityEngine.Debug.Log("0000000000000000000"); if (G != null) { m_LuaInitCall = G.GetInPath <InitGameDelegate>("InitGame"); UnityEngine.Debug.Log("1111111111111111111"); m_LuaGetInitProCall = G.GetInPath <GetInitProgressDelegate>("GetInitProgress"); UnityEngine.Debug.Log("2222222222222222222"); GameObject go = CoreEntry.gResLoader.ClonePre("UI/Prefabs/Start/FirstRes/UIInit", null, false); InitUI = go.transform.GetComponent <UIInitGame>(); RawImage bg = go.transform.Find("Back").GetComponent <RawImage>(); if (null != bg) { bg.texture = ThirdPartyEntry._textureBg; } InitUI.SetProgress(0); StartCoroutine(InitProcess()); } }
IEnumerator InitProcess() { WaitForEndOfFrame wait = new WaitForEndOfFrame(); float gap = 0.05f; float time = 0.0f; float lastTime = Time.realtimeSinceStartup; float configPercent = Random.Range(0.8f, 0.9f); if (AppConst.UseAssetBundle) { configPercent = Random.Range(0.3f, 0.5f); } while (!m_LuaInitCall()) { time += Time.realtimeSinceStartup - lastTime; if (time > gap) { lastTime = Time.realtimeSinceStartup; time = 0; InitUI.SetProgress(m_LuaGetInitProCall() * configPercent); yield return(wait); } } m_LuaInitCall = null; m_LuaGetInitProCall = null; yield return(wait); InitUI.SetLoadTip("游戏资源加载中......"); float lastPercent = configPercent + (1 - configPercent) * 0.5f; float displayProgress = configPercent; CoreEntry.gSceneMgr.PreloadScene("Scene/allMap/ui/RoleUI"); while (CoreEntry.gSceneMgr.SceneLoading) { while (displayProgress < lastPercent) //预加载 { displayProgress += 0.005f; InitUI.SetProgress(displayProgress); yield return(wait); } yield return(wait); } lastPercent = 0.99f; CoreEntry.gSceneMgr.PreloadScene("Scene/allMap/ui/LoginUI"); while (CoreEntry.gSceneMgr.SceneLoading) { while (displayProgress < lastPercent) //预加载 { displayProgress += 0.01f; InitUI.SetProgress(displayProgress); yield return(wait); } yield return(wait); } InitEnd(); InitUI.SetProgress(1); yield return(StartCoroutine(MainPanelMgr.LoadStreamTexture(ClientSetting.Instance.GetStringValue("BackLogin"), string.Empty))); yield return(StartCoroutine(MainPanelMgr.LoadStreamTexture(ClientSetting.Instance.GetStringValue("LoginLogo2"), string.Empty))); yield return(StartCoroutine(MainPanelMgr.LoadStreamTexture(ClientSetting.Instance.GetStringValue(string.Format("Bg_loading{0}", UnityEngine.Random.Range(0, 4))), "Bg_loading"))); MapMgr.Instance.EnterLoginScene(); }