位置: 编程技术 - 正文

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

  • 个人所得税申报操作流程2023
  • 税收分类编码表下载2023
  • 购买车辆保险的现金流
  • ibps对公提回贷记分录
  • 哪些单位属于政府工作部门系列
  • 其他应收款的对方科目有哪些
  • 商品的入账价值包括消费税吗
  • 利润表研发费用包括哪些内容
  • 政府补助收入计算有了新变化
  • 专票金额和实际报销金额不符
  • 公司活动发言稿范文
  • 土地使用权入账价值
  • 计提和缴纳税会计分录
  • 房租发票进项税可以抵扣吗
  • 企业申请资产损失需要提供哪些确认证据?
  • 税收征管法实施条例
  • 用友t3修改帐套怎样修改企业会计准则
  • 个税累计预缴税额税率表是年还是月
  • 计提税金和缴纳税金的会计分录
  • 离退休人员福利
  • 会议费税前扣除最新税务规定
  • 新入职员工如何加入企业微信
  • 工效挂钩企业工资税前扣除有何规定?
  • 多交的增值税怎么处理
  • 直接人工成本的计算
  • 存货丢失取得赔偿
  • php页面之间传值
  • 怎么制作网线接口
  • 苹果 macOS 13.3 开发者预览版 Beta 2 发布
  • 公司装修款怎么做分录
  • 融资租入的设备为什么属于资产
  • 无花果的功效与作用对女人的好处
  • Vue3 入门笔记 ---- 利用Element Plus对页面进行布局划分以及实现左侧公共菜单
  • 哈阿公路
  • 期末增值税结转账务处理
  • 出借和出租包装物的区别
  • 购买其他权益工具
  • 资产负债表和利润表的利润不一致
  • typescript教程推荐
  • unix命令大全详解
  • 软件开发增值税减免政策
  • 子公司借钱给母公司使用
  • 设备租赁经营部经营范围
  • 管理费用科目核算的内容
  • 开发票纸巾属于什么编码
  • 纳税人填写纳税申报表
  • 个体户税率征收
  • 数据源suspended
  • 不发工资可以先报警吗
  • 社保所属期怎么填
  • 小规模纳税人的企业所得税怎么算
  • 折旧费和折旧额的区别
  • 差额征税小规模纳税人免税销售额栏次
  • 汽油发票怎么开专票
  • 研发费用不一致说明
  • 外购固定资产的会计处理
  • 一般纳税人的税负率是多少
  • 企业发生的各项罚款收入应计入
  • 贷款公司收取服务费跑路
  • 公司名义送花篮属于什么费用
  • win1020h2累积更新
  • xp系统打开软件慢怎么解决
  • winxp u盘拒绝访问
  • centos6开机启动
  • 运行ghost
  • linux内核和根文件系统的关系
  • win10任务界面
  • win10version20h2的03累积更新
  • Win10无法获取ipv4
  • jquery对动态生成的进行操作
  • shell脚本常用命令及操作
  • 批量数据验证
  • python设计gui
  • js基本代码
  • 税务局风险管理股工作总结
  • 限售股转让如何交税
  • 国家税务总局一个月多少钱
  • 从日本带化妆品回国会被扣吗
  • 收到假发票,被公司辞退
  • 公司财务专用章的用途
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设