位置: 编程技术 - 正文

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中自带事件函数的执行顺序([置顶]电影名字《收件人不详》)

  • 2020年个税申报流程视频
  • 营业额和营业收入区别举例
  • 咨询服务费预收率怎么算
  • 公章未备案是否不合法
  • 软件企业购进软件服务怎么入账
  • 已经抵扣过的进项票对方红冲之后怎么做账报税
  • 初级会计考试税率要记吗
  • 购买的二手车可以抵扣进项税额吗
  • 商业企业销售的产品
  • 出口酒类产品需要什么
  • 以前年度不合规发票怎么处理
  • 通过无偿取得的成果
  • 以前年度发生的费用
  • 房地产销售税额抵减
  • 工地人为受伤一般怎么解决
  • 会计人员应掌握的知识
  • 资产原值包含残值吗
  • 已付款未收到发票
  • 进口付汇核销流程
  • 给客户退差价怎么说
  • 确认递延收益纳税调整吗
  • 个人到财务挂账怎么做账
  • 营业外收入属于什么会计要素
  • 国际货运运费的计算基础
  • php正则表达式验证url
  • 银行存款日记账怎么记账
  • 股份支付的成本费用可否税前扣除?
  • 销售折扣的会计分录处理
  • php bcsub
  • ssms注释
  • 游戏运营服务是做什么的
  • 银行提取现金会查征信吗
  • arc架构
  • php下载功能
  • 本年利润的会计科目
  • 蓝桥杯web开发 618
  • 【强化学习】Q-Learning算法详解
  • timedatectl命令用法
  • 低值易耗品费用部门
  • 票据权利的取得要件
  • 个人所得税法实施细则2023
  • 什么是企业会计确认计量和报告的空间范围
  • 控股子公司注销公告是利空吗
  • 个人出租不动产增值税优惠政策
  • 广告公司工程部
  • 个人所得税规定的免纳个人所得税的范围
  • 贸易公司开发票进项跟销项不符合怎么办?
  • 借款怎么入会计分录
  • 接收商业承兑汇票有风险吗
  • 补助是工资以外的吗
  • 账上存货太多实收怎么办
  • 教育局可以接受捐赠吗
  • 购买商品属于什么费用
  • 税金及附加科目核算
  • 人力公司开的代驾发票
  • 销售商品结转成本的记账凭证
  • 购物卡送给客户的账务处理
  • 专用发票怎么入账
  • 长期待摊费用什么时候结束摊销
  • 工业企业增值税负率一般控制在多少
  • mysql保留整数
  • 用OpenBSD 3.8 release自带的FTPD架设FTP服务器
  • win7系统开启vt
  • windows xp远程控制
  • linuxsleep函数
  • setlang.exe - setlang是什么进程 有什么用
  • find.exe应用程序错误
  • 关机你的电脑遇到问题,需要重新启动,我们只收集
  • 飞完整版歌曲
  • ftp如何上传数据
  • html5翻页效果
  • Node.js中的construct构造函数
  • 创建ie浏览器
  • node js连接数据库
  • angular const
  • android基础入门教程
  • 农商银行股权分红如何计算
  • 医院能开增值税开发票吗
  • 如何参与发票摇奖
  • 台州土地成交
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设