位置: 编程技术 - 正文

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

  • 固定资产处置营业外收入和发票金额不一致
  • 公司处理固定资产的账务处理
  • 未完工工程如何做绩效评价
  • 赠品不开票如何做账
  • 外包工加工工资怎么结算
  • 保证金抵扣货款合同
  • 投资者投入固定资产的成本
  • 公司发放节日礼品
  • 电商公司怎么开发票
  • 建筑企业如何进行资质申请?
  • 进项税额转出凭证怎么做
  • 股权购买会计分录
  • 递延资产摊销属于什么科目
  • 固定成本与变动成本的区别
  • 用企业资本金购物违法吗
  • 关联企业之间的咨询费
  • 公账的钱如何合法取出会计
  • 如何调用金三接口?
  • 存出投资款是什么凭证
  • 金税盘技术维护费可以抵扣吗
  • 政府性基金收入是政府非税收入吗
  • 哪些资产类科目增加记贷方
  • 企业票据贴现费怎么算
  • 怎么查发票的真假鉴定
  • 赠送礼品进项税需要转出吗
  • 固定资产减值准备可以转回吗
  • php获取长度
  • cssschool
  • win11磁盘分区后不显示
  • unzip解压命令参数
  • 房地产企业预缴增值税会计处理
  • 企业计提养老保险分录
  • 已收到货款 还未发货的会计处理
  • 企业改制资产整合过程中涉及的土地增值税
  • 固定资产加速折旧是什么意思
  • 间接费用允许调整吗
  • 保证人不承担责任的情形(上)
  • 小规模小于30万之前计提的税金及附加税
  • 软件企业该怎么发展起来
  • 零税率与免税有关系吗
  • 销售bu是什么意思
  • 材料采购如何做好市场调研工作
  • 收入增长率计算器
  • 应收账款的注意要点
  • 给离退休人员发放以前年度在岗奖金需要计提工会经费吗
  • 去年亏损今年有盈利合伙企业怎么交生产经营所得税
  • 汽车4s店收到保险佣金做账
  • 生产加工企业辅导资料
  • 增值税退税账务处理,经其他收益科目
  • 工会经费网上怎么申报
  • 土地转移是什么意思
  • 盈余公积多计提对报表的影响
  • 员工的生育津贴怎么发放
  • 加油充值卡有优惠吗
  • 企业薪资制度
  • 国家规定房屋买卖中介费
  • 账户利息计入什么科目
  • 可转债举例说明
  • 固定资产怎么计算折旧额
  • 怎么调整原材料的数量和单价
  • sql常用语句大全简书
  • mysql5717安装及配置超详细教程
  • 组策略 guest
  • dwrg_repair.exe什么意思
  • mac红
  • win8.1 蓝屏
  • mac命令行窗口怎么打开
  • linux CentOS/redhat 6.5 LVM分区使用详解
  • SetPoint.exe - SetPoint是什么进程 有什么用
  • Linux查看文件的大小
  • window.location.href用法
  • 编写批处理
  • 批处理删除指定后缀名
  • opencv人脸识别模型训练
  • dos help命令
  • node.js 定时任务
  • Android之Async-http
  • js math.js
  • 常用的截图方法有哪些
  • 资源税选矿和原油的区别
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设