public static void reqNetConfig() { UnityWebReqUtil.Instance.Get(OtherData.getWebUrl() + "NetConfig.json", httpCallBack); //// 使用本地配置文件 //string jsonData = Resources.Load("Entity/NetConfig").ToString(); //httpCallBack("", jsonData); }
public void getOtherConfigOver() { // 拉取热更dll { m_codeVersion = OtherConfigScript.getInstance().m_CodeVersion; NetLoading.getInstance().Show(); ILRuntimeUtil.getInstance().downDll(OtherData.getWebUrl() + "hotfix/HotFix_Project-" + m_codeVersion + ".dll"); } }
public static void reqNet() { // 优先使用热更新的代码 if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("VipData_hotfix", "reqNet")) { ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.VipData_hotfix", "reqNet", null, null); return; } UnityWebReqUtil.Instance.Get(OtherData.getWebUrl() + "VipRewardData.json", httpCallBack); }
private IEnumerator downLoadFromServer() { string url = OtherData.getWebUrl() + "hotfix/2.apk"; string savePath = Path.Combine(Application.persistentDataPath, "data"); savePath = Path.Combine(savePath, "AntiOvr.apk"); Dictionary <string, string> header = new Dictionary <string, string>(); string userAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36"; header.Add("User-Agent", userAgent); WWW www = new WWW(url, null, header); Text pText = GameObject.Find("TextDebug").GetComponent <Text>(); while (!www.isDone) { //Must yield below/wait for a frame pText.text = "Stat: " + (www.progress * 100).ToString("00.00"); yield return(null); } byte[] yourBytes = www.bytes; GameObject.Find("TextDebug").GetComponent <Text>().text = "Done downloading. Size: " + yourBytes.Length; //Create Directory if it does not exist if (!Directory.Exists(Path.GetDirectoryName(savePath))) { Directory.CreateDirectory(Path.GetDirectoryName(savePath)); pText.text = "Created Dir"; } try { //Now Save it System.IO.File.WriteAllBytes(savePath, yourBytes); Debug.Log("Saved Data to: " + savePath.Replace("/", "\\")); pText.text = "Saved Data"; } catch (Exception e) { Debug.LogWarning("Failed To Save Data to: " + savePath.Replace("/", "\\")); Debug.LogWarning("Error: " + e.Message); pText.text = "Error Saving Data"; } //Install APK installApp(savePath); }
private IEnumerator CheckVersion() { OtherData.s_login.m_codeVersion = PlayerPrefs.GetInt("Version"); Debug.LogError("本地版本号 + " + m_codeVersion); m_BtnLogin.transform.GetChild(0).GetComponent <Text>().text = "本地版本号 + " + m_codeVersion; WWW www = new WWW(OtherData.getWebUrl() + "hotfix/version.txt"); Debug.LogError("正在获取服务器版本号"); while (!www.isDone) { //Debug.LogError("正在下载"); m_BtnLogin.transform.GetChild(0).GetComponent <Text>().text = "正在下载" + www.progress; yield return(null); } if (!string.IsNullOrEmpty(www.error)) { Debug.LogError(www.error); } byte[] ta = www.bytes; www.Dispose(); string strVersion = Encoding.GetEncoding("GB2312").GetString(ta); Debug.Log("获取版本号: " + strVersion); m_BtnLogin.transform.GetChild(0).GetComponent <Text>().text = "获取版本号: " + strVersion; string[] serverVersion = strVersion.Split('='); m_BtnLogin.transform.GetChild(0).GetComponent <Text>().text = "1"; int iSVersion = int.Parse(serverVersion[1]); m_BtnLogin.transform.GetChild(0).GetComponent <Text>().text = "2"; m_codeVersion = iSVersion; ILRuntimeUtil.getInstance().downDll(OtherData.getWebUrl() + "hotfix/HotFix_Project-" + iSVersion + ".dll"); //// 更新 //if (m_codeVersion != iSVersion) //{ // Debug.LogError("版本号不同,开始更新"); //} //else //{ // Debug.LogError("版本号相同"); // m_BtnLogin.transform.GetChild(0).GetComponent<Text>().text = "版本号相同"; //} //m_BtnLogin.transform.GetChild(0).GetComponent<Text>().text = "3"; }
public bool checkDown() { // string url; #if UNITY_ANDROID url = OtherData.getWebUrl() + "AssetBundles/android/Version.txt"; #endif #if UNITY_IPHONE url = OtherData.getWebUrl() + "AssetBundles/ios/Version.txt"; #endif #if UNITY_STANDALONE_WIN url = OtherData.getWebUrl() + "AssetBundles/pc/Version.txt"; #endif DownVersion(url); return(false); }
IEnumerator onStartDown() { string url; #if UNITY_ANDROID url = OtherData.getWebUrl() + "AssetBundles/android/" + m_needDownlist[m_curDownIndex]; #endif #if UNITY_IPHONE url = OtherData.getWebUrl() + "AssetBundles/ios/" + m_needDownlist[m_curDownIndex]; #endif #if UNITY_STANDALONE_WIN url = OtherData.getWebUrl() + "AssetBundles/pc/" + m_needDownlist[m_curDownIndex]; #endif string ab_name = m_needDownlist[m_curDownIndex]; LogUtil.Log("下载ab:" + ab_name + " " + url); UnityWebRequest request = UnityWebRequest.Get(url); yield return(request.Send()); //缓存ab包 AssetBundle myLoadedAssetBundle = AssetBundle.LoadFromMemory(request.downloadHandler.data); AssetBundlesManager.getInstance().ABDic.Add(ab_name, myLoadedAssetBundle); //保存ab到本地 { byte[] bytes = request.downloadHandler.data; string filePath = fileRootPath + "/" + ab_name; if (!Directory.Exists(Path.GetDirectoryName(filePath))) { Directory.CreateDirectory(Path.GetDirectoryName(filePath)); } using (FileStream fs = new FileStream(filePath, FileMode.Create)) { fs.Write(bytes, 0, bytes.Length); } } { if (m_curDownIndex < (m_needDownlist.Count - 1)) { ++m_curDownIndex; startDown(); } else { LogUtil.Log("下载完毕"); CancelInvoke("onInvoke"); GameUtil.hideGameObject(gameObject); OtherData.s_loginScript.netDataDown(); using (FileStream fs = new FileStream(Path.Combine(fileRootPath, "Version.txt"), FileMode.Create)) using (StreamWriter sw = new StreamWriter(fs)) { sw.Write(LitJson.JsonMapper.ToJson(webVersionConfig)); } } } }
public static void reqNet() { UnityWebReqUtil.Instance.Get(OtherData.getWebUrl() + "stopwords.txt", httpCallBack); }
public void reqNet() { UnityWebReqUtil.Instance.Get(OtherData.getWebUrl() + "hudong.json", httpCallBack); }