位置: 编程技术 - 正文

unity3d在线更新资源(4)(unity 更新)

编辑:rootadmin

推荐整理分享unity3d在线更新资源(4)(unity 更新),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:unity 更新,unity3d怎么更新,如何更新unity hub,unity3d怎么更新,unity3d怎么更新,unity3d怎么更新,unity更新下载文件,unity3d怎么更新,内容如对您有帮助,希望把文章链接给更多的朋友!

unity3d在线更新资源(4)(unity 更新)

经过一天的尝试,终于确认方案可行,主要代码如下:

using UnityEngine;using System.IO;using System.Threading;using SevenZip;using Awesome.Net.Compression;using System.Collections;using System.Collections.Generic;public class VersionCheckControl:MonoBehaviour{ ProgressBar bar; string[] path; string dic; UILabel progress; UILabel checkVersionLabel; Dictionary<string, bool> compressDic = new Dictionary<string, bool>(); void Awake() { bar = transform.Find ("Progress2").GetComponent<ProgressBar> (); progress = bar.transform.Find ("Label").GetComponent<UILabel> (); UILabel label = bar.transform.Find ("Tip").GetComponent<UILabel> (); label.text = Localization.Get (""); checkVersionLabel = transform.Find ("CheckVersionLabel").GetComponent<UILabel> (); checkVersionLabel.text = Localization.Get (""); bar.gameObject.SetActive (false); } void Start() { StartCoroutine (downLoadVersionFile ()); } string serverVersion; string localPath; string assetVersionStr; string localAssetPath; List<string> needDownList = new List<string>(); IEnumerator downLoadVersionFile() { WWW versionWWW = new WWW (PlatformConfig.ServerVersionPath() &#; "Version"); yield return versionWWW; if(versionWWW.error != null) { Debug.Log(versionWWW.error); checkVersionLabel.text = Localization.Get (""); } else { serverVersion = StringUtil.removeHuiChe(versionWWW.text); localPath = Application.persistentDataPath &#; "/Version"; if(File.Exists(localPath)) { string localVersion = File.ReadAllText(localPath); if(localVersion == serverVersion) { checkVersionLabel.gameObject.SetActive(false); startConnect(); } else { StartCoroutine(DownLoadAssetVersionFile()); } } else { StartCoroutine(DownLoadAssetVersionFile()); } } } IEnumerator DownLoadAssetVersionFile() { WWW assetVersion = new WWW(PlatformConfig.ServerVersionPath() &#; "AssetVersion"); yield return assetVersion; if(assetVersion.error != null) { File.WriteAllText(localPath, serverVersion); checkVersionLabel.gameObject.SetActive(false); startConnect(); } else { assetVersionStr = StringUtil.removeHuiChe(assetVersion.text); localAssetPath = Application.persistentDataPath &#; "/AssetVersion"; Dictionary<string, int> localAsset = new Dictionary<string, int>(); if(File.Exists(localAssetPath)) { string localAssetStr = File.ReadAllText(localAssetPath); string[] localAssetArr = localAssetStr.Split('|'); for(int i = 0; i < localAssetArr.Length; i&#;&#;) { string[] arr = localAssetArr[i].Split('-'); localAsset.Add(arr[0], int.Parse(arr[1])); } } string[] serverAssetArr = assetVersionStr.Split('|'); for(int i = 0; i < serverAssetArr.Length; i&#;&#;) { string[] arr = serverAssetArr[i].Split('-'); string key = arr[0]; int serverAssetVersion = int.Parse(arr[1]); if(!localAsset.ContainsKey(key) || localAsset[key] < serverAssetVersion) { needDownList.Add(key); } } StartCoroutine(DownLoadBundleFile()); } } WWW bundle; int index = 0; bool isAllDone = false; IEnumerator DownLoadBundleFile() { checkVersionLabel.gameObject.SetActive (false); if(needDownList.Count <= 0) { File.WriteAllText(localPath, serverVersion); startConnect(); } else { bar.gameObject.SetActive(true); for(int i = 0; i < needDownList.Count; i&#;&#;) { bundle = new WWW(PlatformConfig.ServerVersionPath() &#; needDownList[i] &#; ".assetBundle"); yield return bundle; if(bundle.error != null) { Debug.Log(bundle.error); } else { File.WriteAllBytes(PlatformConfig.PathOfArchive() &#; needDownList[i] &#; ".assetBundle", bundle.bytes); } index&#;&#;; } File.WriteAllText(localAssetPath, assetVersionStr); File.WriteAllText(localPath, serverVersion); isAllDone = true; } } void Update() { if(bar.gameObject.activeSelf) { bar.setValue (bundle.progress / needDownList.Count &#; index / needDownList.Count, true); progress.text = Mathf.CeilToInt(bar.getValue() * ).ToString() &#; "%"; if(isAllDone && bar.getValue() >= 1f) { startConnect(); isAllDone = false; } } } void startConnect() { bar.gameObject.SetActive (false); ResManager.getInst ().preLoadBundle (); LoginAction action = GetComponent<LoginAction>(); action.startConnect(); } }整体思路还是很简单的,就是先把流程走通。我也觉得目前的方案应该是最好的选择。

[置顶] Unity3D中自带事件函数的执行顺序 在Unity3D脚本中,有几个Unity3D自带的事件函数按照预定的顺序执行作为脚本执行。其执行顺序如下:编辑器(Editor)Reset:Reset函数被调用来初始化脚本

Unity3d中调用webservice方法 在此之前非常感谢一位博客主的博客,是这位仁兄帮我找到了思路:

u3d在线更新资源方案 现附上雨松大神的文章:

标签: unity 更新

本文链接地址:https://www.jiuchutong.com/biancheng/378735.html 转载请保留说明!

上一篇:Unity3d MonoDevelop格式化代码

下一篇:[置顶] Unity3D中自带事件函数的执行顺序([置顶]电影名字《收件人不详》)

  • 印花税计算是否含税
  • 增值税专用发票抵扣期限
  • 公允价值变动损益属于什么科目
  • 项目税后现金流量的计算方法
  • 增值税销项税额账务处理
  • 注册公司认缴出资方式怎么选
  • 银行询证函快递怎么查
  • 个税专项附加扣除
  • 存在问题的具体表现和产生问题的原因分析
  • 对方公司倒闭应收账款发票还需要开吗
  • 车辆生产企业目录
  • 发票冲销后还能用吗
  • 小规模纳税人租赁发票税率是多少
  • 受托软件开发不转让著作权的账务处理
  • 工会费入账科目
  • 减免所得税怎么算税率
  • 2008版增值税普通发票图片
  • 企业从事生产经营活动时所持有的基本信念
  • 企业转让二手房增值税
  • 有限公司属于什么企业
  • 收到投资款怎么做凭证
  • 何为风险报酬?
  • 六税两费包括哪三税
  • 应纳税所得额未减上季度所得税,下季度可补减吗
  • 企业季度所得税可以弥补以前年度亏损吗
  • 外贸出口企业的租金能退税吗
  • 如何在excel中取最早与最晚
  • 无法找到脚本文件c:\windows\system32
  • 职工福利费算职工薪酬吗
  • 取得土地所有权范围内的树如何处理
  • 健康助手在哪里找到
  • php 用户和密码
  • real system
  • 向银行借入长期借款50万元
  • 利息支出属于生产成本吗
  • windows 11 正式版实际使用体验如何?
  • 玩游戏的显示器要高刷还是高分辨率
  • 电脑上fci是什么文件
  • 记账凭证填制的依据
  • 外购产品会计分录
  • 黑尾鮰鱼
  • 出让土地使用权和转让土地使用权的区别
  • php怎么添加背景图片
  • docker-p
  • 市职工报销比例多少
  • 软件行业的最后阶段是
  • timedatectl命令用法
  • 营业税金及附加税率
  • phpcms怎么样
  • electron开发的应用程序
  • java一维数组从小到大排序
  • mysql_real_query
  • 兼职劳务费个税计算器
  • 税金及附加可以结转吗
  • 专用发票与普通发票的区别有
  • 小规模销售免税产品需要交税吗
  • 商贸企业增值税税负率低于1%则存在涉税问题
  • 房地产企业土地增值税预缴
  • 药店医保收入如何查询
  • win8下载软件
  • 播放windows xp
  • 怎么更改win7
  • windows 10的屏幕键盘快捷键在哪里
  • win 7关闭睡眠
  • 怎么用windows
  • javascript基础
  • ExtJS中设置下拉列表框不可编辑的方法
  • 页面模板排序
  • node.js操作文件
  • 链接符怎么删除
  • linux ls-l命令
  • jquery中绑定和解绑的事件有哪些
  • Python中强大的命令行库click入门教程
  • python简单实现刷新智联简历
  • js特殊字符有哪些
  • jQuery插件cxSelect多级联动下拉菜单实例解析
  • jquer选择器
  • 小规模纳税人达到一般纳税人标准
  • 推动税务系统全面从严
  • 国税申报作废怎么操作
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设