位置: 编程技术 - 正文

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

  • 房产税的计算方法举例说明
  • 计提附加税会计凭证怎么做会计分录
  • 什么是边际税率高
  • 缴纳个税会计分录是什么
  • 个人劳务报酬怎么申报个税
  • 企业所得税季度申报时间
  • 小规模纳税人场地租赁
  • 预付材料购货款计入什么科目
  • 金税盘维护费减免政策代码
  • 委托加工合同如何标注多个地址
  • 所得税预提多了怎么处理
  • 小规模都纳什么税
  • 企业交税的钱用在哪里
  • 月饼税收分类属于哪一类食品
  • 总包劳务工资发什么科目
  • 纳税人证明是完税证明吗
  • 设备销售和安装账务
  • 借款利息税前扣除比例
  • 企业所得税清算报备是什么意思
  • 债务转为资本什么意思
  • 个人业务费是什么
  • 坏账计提方法和比例
  • 增值税免税项目和免征增值税的区别
  • 补缴社保公积金
  • win10任务栏搜索如何关闭
  • 限额领料单一般一式几联
  • windows11怎么操作
  • 公司福利放置零食文案
  • 若依框架搭建
  • 单位未足额缴纳社保可以补交几年
  • thinkphp框架搭建
  • 资金平衡表的编制方法
  • window cuda
  • unplugin-auto-import/vite
  • vue动态绑定背景图
  • eyring模型
  • 物流公司的会计好做吗
  • 大气污染物排放2020标准
  • c语言指针妙用
  • 销售人员的工资属于什么会计科目
  • mysql如何分类
  • 红字转账凭证怎样录入
  • 开多少平方超市赚钱
  • 什么叫增值入股
  • 收到非税收入一般缴款书怎么分录
  • 自营工程领用自产产品的处理
  • 进项发票认证多了留抵多久
  • 公司贷款直接打收据吗
  • 材料核销的依据
  • 长期股权投资其他权益变动
  • 分析企业盈余状况
  • 金税盘费用不交会怎么样
  • 其他货币资金都有啥
  • 企业失信是什么意思
  • 其他收入属于什么收入
  • 商品型企业
  • u极速u盘启动官网
  • mac怎么隐藏桌面文件
  • macbookpro 安装
  • 数字签名方法不提供
  • w8系统怎么用
  • linux扩大文件系统
  • cs1.6 linux
  • win8怎么看电脑wifi密码
  • 缺少系统操作怎么办
  • Android性能优化 武汉招聘
  • linux怎么添加新用户
  • opengl 2
  • AndroidSharedpreference数据共享
  • jquery提交form表单数据
  • jquery层级选择器
  • Unity64 AStarPath 寻路失效 Bug解决 IOS64 IL2CPP - Bad date/time format in the zip file
  • javascript快速入门
  • python语句查询
  • android数据存储与访问的方式有
  • 国家税务总局的局长什么级别
  • 宁夏电子税务局官网登录入口首页
  • 社保在线审核
  • 美国非税收入排名榜
  • 开票系统红色预警情况说明怎么写
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设