我正在使用下面的代码,如果捆绑包仅在第一次安装时有效,否则我收到捆绑已存在错误。所以我的问题是如何检查捆绑包是否存在,如果存在,请从缓存的文件中读取它
IEnumerator DownloadAndCache() {
while(!Caching.ready)
yield return null;
using (WWW www = WWW .LoadFromCacheOrDownload(bundleURL, Version)) {
yield return www;
if (www .error != null)
throw new UnityException("WWW Download had an error: " + www .error);
// Must add check mechanism here
AssetBundle bundle = www .assetBundle;
// bundle.Unload(false); this doesnt work
if (AssetName == "") {
mBundleInstance = Instantiate (bundle.mainAsset) as GameObject;
mBundleInstance.transform.parent = cloudtarget.transform;
}
else {
mBundleInstance = Instantiate(bundle.LoadAsset (AssetName)) as GameObject;
mBundleInstance.transform.parent = cloudtarget.transform;
}
}
}
谢谢
答案 0 :(得分:0)
所有缓存的资产包都是按名称访问的,如果资产包的名称是abc则使用:
Caching.IsVersionCached(AssetBundleName, version) // AssetBundleName = "abc"
还记得另外一件事,说出重要的事情,例如, 如果您从http://somewibsite.com/AssetBundle/abc下载资产包,则将忽略所有域部分,并且仅将名称abc保存为资产包名称。