【发布时间】:2018-06-19 03:24:19
【问题描述】:
我想知道 AssetBundle 已经在缓存中。这通常使用Caching.IsVersionCached 函数来完成。
Unity 2017.1 不再支持 Caching.IsVersionCached(string url, int version) 函数重载。
Unity 2017.3 建议我使用Caching.IsVersionCached(string url, Hash128 hash) 重载。
我不知道Hash128 是什么以及如何获取和使用它。 Hash128 是用来做什么的?如何从 AssetBundle 中获取它?
感谢您的回答。
但我无法解决我的问题。
这是我的代码
for (int i = 0; i }
我的目的是当assetbundle已经在缓存中时,继续并需要下载,在PopUp_YesORNoForAssetBundle上设置。 检查assetbundle下载或版本检查时需要hash128。 但在您的解释中,hash128 仅在上次加载或保存资源文件夹中的清单文件后才能获得。 我想知道如何检查assetbunle 是否在缓存中。 如果你建议的方式,我真的很感谢你。while (!Caching.ready)
yield return null;
string url = GetUrl(assetInfoList[i].assetbundle_name);
string keyName = url + assetInfoList[i].version_no.ToString();
using (UnityWebRequest request = UnityWebRequest.GetAssetBundle(url,(uint)assetInfoList[i].version_no, 0))
{
if (Caching.IsVersionCached(url, assetInfoList[i].version_no) == true)
continue;
if (i == 0)
{
string wifiConnectRecommend = Message.Ins.WIFI_ONLY;
PopUpManager.Instance.PopUp_YesORNoForAssetBundle(wifiConnectRecommend.ToString(), ClickWifi, availableBytes, totalBytes);
while (!SceneManager.Ins.isWifiUseConfirm)
yield return null;
}
request.SendWebRequest();
while (request.isDone == false)
{
progressbar.value = request.downloadProgress;
currentCount.text = countString + " (" + (request.downloadProgress * 100).ToString("N2") + "%)";
yield return null;
}
if (request.error != null)
{
Debug.Log("www.error");
}
else
{
AssetBundleRef abRef = new AssetBundleRef(url, assetInfoList[i].version_no);
abRef.assetBundle = DownloadHandlerAssetBundle.GetContent(request);
dictAssetBundleRefs.Add(keyName, abRef);
}
}
【问题讨论】:
-
欢迎来到 Stackoverflow!这个问题需要更多细节。请阅读How do I ask a good question?和How to create a Minimal, Complete, and Verifiable example
标签: c# unity3d assetbundle