Hello!
Almost All my bundles loads fine, but with some of my bundles I get this error:
Error while downloading Asset Bundle: Failed to decompress data for the AssetBundle
And problem is only for WebGL build. For OSX all is ok with loading bundles.
This is my code I use to load bundle.
public IEnumerator LoadAsset(string bundleName, string assetName, Action<GameObject> callback)
{
bool flag_assetIsLoaded = false;
Stopwatch st = Stopwatch.StartNew();
AssetBundle bundle = null;
string s = "";
bundle = CheckBundleLoaded(bundleName);
flag_sceneIsLoaded = bundle != null;
s += "Сheck bundle time:" + st.ElapsedMilliseconds + " ";
string assetBundleName = bundleName;
string url = Application.dataPath;
if(url[url.Length - 1] != '/') url = string.Concat(url,"/");
url = URLReturn(url,assetBundleName);
if(!flag_assetIsLoaded)
{
st = Stopwatch.StartNew();
var uwr = UnityWebRequestAssetBundle.GetAssetBundle(url);
UnityWebRequestAsyncOperation uwrao = uwr.SendWebRequest();
while(!uwrao.isDone)
{
progress = uwrao.progress;
yield return null;
}
s += "Request time:" + st.ElapsedMilliseconds + " ";
st = Stopwatch.StartNew();
bundle = DownloadHandlerAssetBundle.GetContent(uwr);
s += "Content time:" + st.ElapsedMilliseconds + " ";
flag_assetIsLoaded = true;
}
st = Stopwatch.StartNew();
AssetBundleRequest abr = bundle.LoadAssetAsync(assetName);
while(!abr.isDone)
{
progress = abr.progress;
yield return null;
}
callback(abr.asset as GameObject);
s += "LoadAsset time:" + st.ElapsedMilliseconds + " ";
#if DEBUG_LOG
UnityEngine.Debug.Log("Bundle:" + bundleName + "Asset" + " " + abr.asset.name + " " + s );
#endif
bundle.Unload(false);
}
What’s can be wrong?
Unity 2018.2