- Home /
Loading Webplayer builds via WWW.LoadFromCacheOrDownload
I want to download a webplayer build through WWW.LoadFromCacheOrDownload() and load it using WWW.LoadUnityWeb():
WWW cachedDownload = WWW.LoadFromCacheOrDownload( "web_build.unity3d", version );
yield return cachedDownload;
if ( cachedDownload.error != null )
{
Debug.LogError( cachedDownload.error );
cachedDownload.Dispose();
yield break;
}
else
{
cachedDownload.LoadUnityWeb();
}
But as soon as the download is finished I'm getting the error "Cannot load cached AssetBundle." Downloading the same file using the usual WWW constructor works fine. I have a valid Unity Caching License and the caching in general is working, so that is not causing any problems. I guess that the web build is treated like an AssetBundle on deserialization and that is of course failing.
So my question is - were web builds never considered to be cachable or is this a bug?
Thanks, Thomas
Answer by Tommynator · Nov 26, 2010 at 03:53 AM
The easiest workaround I found so far is, to just create an AssetBundle from the complete scene by building it as streamed scene:
BuildPipeline.PushAssetDependencies();
//create asset bundle
BuildPipeline.BuildPlayer(new string[] { "MyScene.unity" }, "AssetBundle.unity3d", BuildTarget.WebPlayer, BuildOptions.BuildAdditionalStreamedScenes);
//create webplayer build
BuildPipeline.BuildPlayer(new string[] { "MyLoader.unity", "MyScene.unity" },"Player.unity3d", BuildTarget.WebPlayerStreamed, BuildOptions.ShowBuiltPlayer);
BuildPipeline.PopAssetDependencies();
And then load the bundle inside of my loader scene the following way:
WWW cachedDownload = WWW.LoadFromCacheOrDownload("MyScene.unity3d", 1);
yield return cachedDownload;
//load the asset bundles
cachedDownload.assetBundle.LoadAll();
//load game level
Application.LoadLevel(1);
That seems to work pretty fine and the unity caching is kicking in too :)
Answer by Dreamora 1 · Nov 24, 2010 at 09:18 AM
do you own a cache addon license? otherwise you can't use the unity webplayer caching technology and have to create assetbundles that are small enough for the browser to keep it in his cache
He said in the question: "I have a valid Unity Caching License". :-)
Yes, as I said I have a valid License and the caching is working perfectly for AssetBundles. The key difference is, that I want to use caching for web builds. I didn't find any information about if that is actually possible. I just assumed it would cache everything that is downloadable in a regular way too.
Answer by mMrDude · Jul 27, 2011 at 03:03 PM
How much does a cache license cost? Heard it is quite expensive but haven't been able to source a price, yet.
Your answer
Follow this Question
Related Questions
Web player cache 1 Answer
Quit application while downloading with www.loadfromcacheordownload makes application crash 0 Answers
LoadFromCacheOrDownload is sensibly slower than WWW, why? 1 Answer
LoadFromCacheOrDownload non asset bundles 1 Answer
Does WWW has cache? Any official member can give us a result? 0 Answers