void DownloadGateway() { GameClient.Instance.ips.Clear(); GameClient.Instance.ports.Clear(); #if UNITY_EDITOR if (File.Exists(Application.dataPath + "/../gateway.txt")) { string str = File.ReadAllText(Application.dataPath + "/../gateway.txt"); string[] strs = str.Split(' '); GameClient.Instance.ips.Add(strs[0]); GameClient.Instance.ports.Add(int.Parse(strs[1])); } ChangeCurrentUpdateState(UpdateState.UpdateFinish); #else #if ILRUNTIME_DEBUG && UNITY_STANDALONE_WIN if (ResourceManager.IsILRuntimeDebug) { if (File.Exists(Application.dataPath + "/gateway.txt")) { string str = File.ReadAllText(Application.dataPath + "/gateway.txt"); string[] strs = str.Split(' '); GameClient.Instance.ips.Add(strs[0]); GameClient.Instance.ports.Add(int.Parse(strs[1])); } ChangeCurrentUpdateState(UpdateState.UpdateFinish); } else { #endif string url = ILRuntimeHelper.GetGatewayUrl(); Debugger.Log("gateway url : " + url, true); string savepath = Application.persistentDataPath + "/gateway.txt"; Downloader.DownloadFiles(new List <DownloadFile>() { new DownloadFile(url, savepath) }, (obj) => { if (!File.Exists(savepath)) { Debugger.LogError("DownloadGateway 0"); _onShowUpdateStepFail(0); return; } string json = File.ReadAllText(savepath); GatewayConfig gatewayConfig = JsonMapper.ToObject <GatewayConfig>(json); _resourceUpdateTips = gatewayConfig.resourceTips; _versionUpdateTips = gatewayConfig.versionTips; _versionUrl = gatewayConfig.versionUrl; _patchUrl = gatewayConfig.patchUrl; Debugger.Log("vesion url : " + _versionUrl, true); Debugger.Log("patch url : " + _patchUrl, true); string version = ResourceManager.CodeVersion.ToString(); string channelName = ILRuntimeHelper.GetChannelName(); bool find = false; for (int i = 0; i < gatewayConfig.gameVersions.Count; ++i) { if (gatewayConfig.gameVersions[i].version == version) { for (int j = 0; j < gatewayConfig.gameVersions[i].channels.Count; ++j) { var channel = gatewayConfig.gameVersions[i].channels[j]; if (channel.channelName == channelName) { GameClient.Instance.isShenHe = channel.isShenHe; ResourceManager.ResourceUrl = channel.resourceUrl; Debugger.Log("resource url : " + ResourceManager.ResourceUrl, true); GameClient.Instance.ips.AddRange(channel.ips); GameClient.Instance.ports.AddRange(channel.ports); find = true; break; } } } } if (!find) { _onShowUpdateStepFail(1); return; } File.Delete(savepath); if (GameClient.Instance.isShenHe && !GameClient.Instance.BuildSettings.MiniBuild) { ChangeCurrentUpdateState(UpdateState.UpdateFinish); } else { ChangeCurrentUpdateState(UpdateState.ComparServerVersion); } }); #if ILRUNTIME_DEBUG && UNITY_STANDALONE_WIN } #endif #endif }