0

我正在使用下面的代码,如果捆绑包仅是第一次安装它就可以工作,否则我会收到捆绑包已经存在的错误。所以我的问题是如何检查捆绑包是否存在,如果存在,从缓存文件中读取它

    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;
        }
    }
}

谢谢

4

1 回答 1

0

所有缓存的资产包都可以通过它们的名称访问,如果您的资产包的名称是 abc,则使用:

Caching.IsVersionCached(AssetBundleName, version) // AssetBundleName = "abc"

记住另外一件重要的事情,例如,如果您从http://somewibsite.com/AssetBundle/abc下载资产包,那么所有域部分都将被忽略,只有名称 abc 被保存为您的资产包名称。

于 2016-09-27T11:22:09.010 回答