位置: 编程技术 - 正文

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

  • 应交税费应交增值税明细账怎么填
  • 小规模出售固定资产税率
  • 无法支付其他应付款说明
  • 增值税加计扣除账务处理
  • 现金折扣净额法税
  • 员工借款会计科目
  • 用友u8怎样查询上个月凭证
  • 给客户办理分期
  • 公司取得增值税怎么算
  • 未达起征点企业怎么处理
  • 资产负债表应交税费计算公式
  • 发票认证信息怎么填
  • 企业所得税的罚款比例
  • 桌面图标被篡改怎么办
  • 捷波主板141m
  • php数字转换大写
  • 软件测试费计入什么科目
  • php基础入门教程
  • rds selected
  • 土地增值税清算收入如何确定
  • drvmgr.exe
  • react img onerror
  • 刷票系统能看出来吗
  • 劳务派遣如何做绩效考核
  • 增值税发票与实际差异五毛钱
  • 小狐狸803050
  • 豁免债权如何做账
  • php不能通过浏览器运行吗
  • php对接第三方支付教程
  • 税务系统申报表
  • 城建税减征50%
  • 小规模纳税人残保金申报时间
  • cvpr2020目标跟踪
  • cp命令使用
  • ip6tables-save命令 保存ip6tables表配置
  • sensor tester
  • WordPress 浏览量修改
  • 公司股东利润分配方案范本
  • 品牌代理费计入什么费用
  • 申请一般人纳税需要什么东西
  • 如何做进项税额转出处理
  • 退回发票金额是什么意思
  • 试生产期间发生事故后重新
  • 汽车租赁属于有形动产融资租赁服务?
  • 经营活动现金净流量为正说明什么
  • 税盘开票机号怎么看
  • 建筑工程发票来自哪里
  • sql server怎么创建约束
  • 预付款已经开了发票未到货要怎么做账
  • 防伪税控技术
  • 房屋维修基金交给哪个部门
  • 超市的进场费怎么入会计科目
  • 残保金补申报需要交滞纳金吗
  • 发票没交税可以报销吗
  • 发票系统升级后怎样开票
  • 五证合一办理步骤
  • mysql中的null值和空
  • xtrabackup备份原理
  • linux下mysql开启远程访问权限 防火墙开放3306端口
  • 如何修改windows注册表
  • mac怎么设置开机默认windows
  • linux系统bug
  • centos 查看用户命令
  • linux滚动更新是什么
  • 软件生态圈是什意思
  • win8系统怎么设置共享局域网
  • win7旗舰版系统激活密钥
  • linux怎么把网卡down
  • 360修复win7
  • unity如何避免碰撞穿透
  • 游戏开发指南笔趣阁
  • animate javascript
  • node.js解析excel
  • easyui messager alert 三秒后自动关闭提示的实例
  • javascript web开发
  • JavaScript中的数据类型分哪为两大类?
  • 即征即退什么时候确认收入
  • 竣工交付的资产有哪几种
  • 汽车销售环节要做什么
  • 问一下医院
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设