位置: 编程技术 - 正文

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 搜狗
  • 常见内存大小
  • 企业所得税如何计算
  • 开票税点算什么费用
  • 进项税额转出如何做账分录
  • mac本host文件
  • mac计算器怎么变小
  • 不动产在建工程领用原材料的分录
  • PHP:pg_set_client_encoding()的用法_PostgreSQL函数
  • hue环境搭建
  • 借入长期借款的利息
  • 易北河流量
  • 冰河湖怎么去
  • 企业收到政府奖励会计分录
  • php的用处
  • php json 对象
  • 公章是否必须备案
  • vue自定义指令生命周期
  • 数字图像处理课后题答案
  • 大二期末要考试吗
  • 银行同业利率
  • 债务重组开场白
  • php 多进程
  • 织梦程序
  • 小规模纳税人与一般纳税人的区别表现在小规模纳税人
  • 核定扣除投入产品怎么算
  • 同一控制下企业合并发生的审计费用计入
  • 个人独资企业应税生产经营所得可以扣除税金支付
  • 开一家公司的具体步骤
  • 贴现凭证的分录
  • 公司加班的餐费怎么算
  • 融资租赁本金和租金的区别
  • 劳务公司开出发票没有收到钱,怎么做成本
  • sql 建索引
  • sqlserver按时间查询
  • linux增加命令
  • soapui安装与配置
  • Ubuntu keylin 14.04 怎么使用root用户登录?
  • Win10技巧:如何开启隐藏的锁屏时间设置项
  • 隐藏文件或文件夹
  • win7为什么不能设置滑动关机
  • 如何配置centos7的ip地址
  • 2021年win10累积更新
  • win10更新总失败
  • 升级win10系统后无法联网的三种解决方法
  • opengl programming guide
  • 一键删除通讯录联系人
  • bootstrap要学吗
  • [置顶]bilinovel
  • super函数python
  • 如何查询发票代码和发票号码
  • 一般纳税人提供公共交通运输服务免征增值税
  • 地税管理员是干什么的
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设