修补 AssetBundle 很简单,只需要下载新的 AssetBundle 并替换现有的 AssetBundle。如果使用 WWW.LoadFromCacheOrDownload
或 UnityWebRequest
来管理应用程序的缓存 AssetBundle,则将不同的版本参数传递给所选 API 将触发新 AssetBundle 的下载。
在修补系统中要解决的更难的问题是检测要替换的 AssetBundle。修补系统需要两个信息列表:
修补程序应下载服务器端 AssetBundle 列表并比较这些 AssetBundle 列表。应重新下载缺少的 AssetBundle 或已更改版本控制信息的 AssetBundle。
也可以编写一个自定义系统来检测 AssetBundle 的更改。自己编写系统的大多数开发人员会选择对 AssetBundle 文件列表使用行业标准数据格式(例如 JSON)和并使用标准 C# 类(例如 MD5)来计算校验和。
Unity 使用以确定方式排序的数据构建 AssetBundle。因此,具有自定义下载程序的应用程序可以实现差异修补。
Unity 不提供任何内置的差异修补机制,并且 WWW.LoadFromCacheOrDownload
和 UnityWebRequest
在使用内置缓存系统时都不会执行差异修补。如果需要差异修补,则必须编写自定义下载程序。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.