位置: 编程技术 - 正文

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

  • 个体工商户怎么补交个人所得税
  • 什么是免税合并
  • 国际税收协定是怎样避税的
  • 怎么恢复自然人个人信息
  • 财报一季度
  • 技术入股亏损如何清算
  • 2019小微企业10万免税需要如何办理
  • 出口业务退税流程资料
  • 怎么计提应交税费
  • 出租固定资产取得的租金收入属于什么收入
  • 现金比率的计算公式是指
  • 子公司取得的投资收益
  • 开给学校的发票要税号吗
  • 建筑行业劳务费开发票可以开工程款吗?
  • 税收分类编码选错了有事吗
  • 总分类账户和明细分类账户平行登记的内容可以概括为
  • 不计入工资薪金所得的有哪些补贴
  • 给客户退差价怎么说
  • 存货盘亏应该计什么科目
  • 咨询费属于什么大类
  • 残保金每年什么时候申报缴纳
  • 社保缴费基数是什么意思,退休能拿多少
  • 哪些人需缴纳个人所得税
  • 一般纳税人税负率是多少
  • 王者荣耀电脑版怎么键盘操作
  • 收到汇算清缴的现金
  • 新准则交易性金融资产
  • media是什么文件
  • 不动产增值税总结
  • 转售股票会计分录
  • 买支票需要带什么章
  • 彩石湖公园门票
  • /locate village村庄
  • mysql_escape_string()函数用法分析
  • 最简单的上传php文件
  • 已提足折旧固定资产改建支出 所得税怎么计算
  • frameworks
  • php网页聊天室
  • 计提坏账准备需要确认递延所得税吗
  • 不良品扣款范本
  • 事业单位应当按月对固定资产计提折旧
  • 现金劳务收入会计分录
  • 专项应付款的账务处理
  • sql建立聚集索引语句
  • 非营利组织免征企业所得税的通知
  • 报销人和经办人的含义
  • 税务现金流量表填错了怎么办
  • 生活垃圾处理费合法吗
  • 预算收入的退付范围
  • 税盘连接服务器失败
  • 普通发票怎么冲红字
  • 工人发生工伤的责任划分
  • 从农民手中购买粮食税率
  • 支付国外客户佣金违法吗
  • 企业正常经营的条件
  • 零申报是不是什么都不用填
  • 相关损坏维修成本是什么
  • 租写字楼水电费自己付吗
  • 不重装系统怎么修复
  • 如何解决脑供血不足
  • fedora gnome
  • mac os xv10.11
  • win1020h2版本千万别更新
  • win7系统禁用网络后如何开启
  • linux常用命令查看
  • win7系统搜索在哪
  • linux给文件赋全部权限
  • linuxat命令的用法
  • 杨辉三角的代码
  • js每天的定时任务
  • Python3.6正式版新特性预览
  • javascript怎么弄
  • js怎么获取密码框内容
  • ORMLite完全解析(四) 官方文档第四章、在Android中使用
  • 东莞市国家税务局网上办税大厅
  • 山西电子税务局手机版
  • 车辆购置税查询平台
  • 出口退税申报系统反馈读入
  • 代账公司盈利水平如何
  • 河南省2020年12月纳税申报截止日期
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设