IEnumerator UpdateProcess() { //APK Update #if UNITY_ANDROID if (Application.platform == RuntimePlatform.Android) { glupgrade.gluInit(); glupgrade.getCallback()._onDownloadChange = OnProcessChanged; glupgrade.getCallback()._onMD5CheckStart = OnMD5CheckStart; glupgrade.getCallback()._onMD5CheckFinish = OnMD5CheckFinish; glupgrade.getCallback()._onDownloadStart = OnDownloadStart; glupgrade.getCallback()._onDownloadFinish = OnDownloadFinished; if (m_slUpdateBar) { m_slUpdateBar.gameObject.SetActive(true); m_slUpdateBar.value = 0.0f; } bool ApkUpdate = false; while (true) { if (SDGlobal.apkUpdateEnable) { if (!ApkUpdate) { int ret = glupgrade.checkNetworkStatus(); if (ret == 1) { Debug.Log("WiFi OK!"); } else if (ret == 2) { Debug.Log("GPRS OK!"); //yield return new WaitForSeconds(10.0f); } else { sdUICharacter.Instance.ShowLoginMsg("APP更新:没有可使用的网络!3秒后重试。"); yield return(new WaitForSeconds(3.0f)); continue; } ApkUpdate = true; ret = glupgrade.InitUpgradeEx(3000); Debug.Log("InitUpgradeEx() return: " + ret); if (ret == 0) // 不需要升级 { Debug.Log("no app update"); break; } else if (ret == 1) // 强制升级 { //sdUICharacter.Instance.ShowLoginMsg("New Version Founded, Please Waiting..."); glupgrade.startUpdate(); } else if (ret == 2)// 非强制升级 { Debug.Log("No Force Update"); //break; } else if (ret == 3) { sdUICharacter.Instance.ShowLoginMsg("APP更新:内部错误(访问升级接口httpCode非200)"); ApkUpdate = false; } else if (ret == 4)// 非强制升级 { sdUICharacter.Instance.ShowLoginMsg("APP更新:内部错误(访问升级接口网络出错)"); ApkUpdate = false; } else if (ret == 5)// 非强制升级 { sdUICharacter.Instance.ShowLoginMsg("APP更新:内部错误(JSON格式转换出错)"); ApkUpdate = false; } else if (ret == 6)// 非强制升级 { sdUICharacter.Instance.ShowLoginMsg("APP更新:获取渠道打包信息失败!"); ApkUpdate = false; } else if (ret == 6)// 非强制升级 { sdUICharacter.Instance.ShowLoginMsg("APP更新:手机SD卡不可用!"); ApkUpdate = false; } else { break; } } yield return(new WaitForSeconds(5.0f)); } else { break; } } } if (m_slUpdateBar) { m_slUpdateBar.gameObject.SetActive(false); } #endif #if UNITY_IPHONE #endif sdUICharacter.Instance.HideLoginMsg(); if (Application.platform == RuntimePlatform.WindowsEditor) { } else { //读取分区信息.. Debug.Log("Read Server Area Information"); while (true) { string AreaID = BundleGlobal.AppVersion()["Area"]; Debug.Log("AreaID=" + AreaID); WWW w = new WWW("http://180.96.39.128:8004/arealist?areaid=" + AreaID); yield return(w); if (w.error == null) { JsonParse jp = new JsonParse(); jp.Parse(w.text); BundleGlobal.Instance.cdn = jp.cdnlist.ToArray(); //BundleGlobal.Instance. //jp.serverlist SDNetGlobal.m_lstSrvInfo = jp.serverlist; SDNetGlobal.serverNotice = jp.notice; SDNetGlobal.defaultServerID = jp.defaultServer; RefreshNotification(jp.Pushlist); break; } else { sdUICharacter.Instance.ShowLoginMsg("读取分区信息错误:" + w.error); } } GetSaveAreaInfo(); } sdUICharacter.Instance.HideLoginMsg(); //bbs if (SDNetGlobal.serverNotice.Length != 0) { sdUICharacter.Instance.ShowbbsWnd(true, SDNetGlobal.serverNotice, true, false); } //Update Bundle BundleGlobal.Instance.StartUpdateAllBundles(); if (m_slUpdateBar) { m_slUpdateBar.gameObject.SetActive(true); } while (BundleGlobal.Instance.updating) { if (m_slUpdateBar && BundleGlobal.Instance.needDownLoadNum > 0) { m_slUpdateBar.value = (float)BundleGlobal.Instance.downloadedNum / (float)BundleGlobal.Instance.needDownLoadNum; if (m_slUpdateBar.value > 0 && m_slUpdateBar.value < 0.022f) { m_slUpdateBar.value = 0.022f; } } if (m_lbUpdateInfo) { int Percent = BundleGlobal.Instance.GetBundlePercent(); if (Percent == 100) { Percent = 99; } string s = Percent + "%]["; if (Percent < 10) { s = "[0" + s; } else { s = "[" + s; } m_lbUpdateInfo.text = "更新资源..." + s + BundleGlobal.Instance.downloadedNum + "/" + BundleGlobal.Instance.needDownLoadNum + "]"; } yield return(0); } if (m_slUpdateBar) { m_slUpdateBar.gameObject.SetActive(false); } if (m_lbUpdateInfo) { m_lbUpdateInfo.text = "加载游戏配置文件..."; } //Load All Config File LoadLevelConfig(); while (m_strLevelConf == "" || m_strLevelLang == "" || m_strLevelMeta == "" || m_strLevelBox == "") { yield return(0); } sdLevelInfo.LoadLevelConfig(m_strLevelConf, m_strLevelLang, m_strLevelMeta, m_strLevelBox); sdResourceDependenceTable.GetSingleton().LoadMonsterTable("$Conf/MonsterDependence.xml", false); sdResourceDependenceTable.GetSingleton().LoadMonsterTable("$Conf/PetDependence.xml", false); sdAITable.GetSingleton().LoadAITable("$Conf/AITable.xml", false); sdConfDataMgr.Instance().Init(false); while (!sdConfDataMgr.Instance().isInitFinish()) { yield return(0); } sdUICharacter.Instance.HideLoginMsg(); //Init GHOME GPUSH if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer) { GHOME_CODE = -2; while (GHOME_CODE != 0) { if (GHOME_CODE == -2) { GHOME_CODE = -1; Debug.Log("InitGHome"); Init_GHOME_GPUSH(); } else { if (GHOME_CODE == 1) { Debug.Log("InitGHome Failed!"); GHOME_CODE = -2; } else { yield return(0); } } } GPUSH_API.Init("791000015", "9728werwerwc53ba8cded5a6a2227dd8"); sdUICharacter.Instance.HideLoginMsg(); } else { m_btEnterGameButton.SetActive(false); SDGlobal.StartGetMacAddress(); } if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer) { UILabel lb_srvName = m_btGameServer.transform.FindChild("Background").FindChild("Label").GetComponent <UILabel>(); lb_srvName.text = SDNetGlobal.serverName; } StartCoroutine(LoginProcess()); }