- Home /
[Asset Bundle] unable to download from server
I am trying to download asset bundle from dropbox and its showing error when it download the file it shows an error as - "NullReferenceException: Object reference not set to an instance of an object". And storing the object of AssetBundle in my own object.like this -
IEnumerator LoadAsset () {
using (WWW www = WWW.LoadFromCacheOrDownload
("https://www.dropbox.com/s/64geijvud5cuci5/MGame?dl=0",1)) {
if (www.error != null)
throw new UnityException ("WWW download had an error:" + www.error);
if (www.assetBundle != null)
{
myAssetBundle = www.assetBundle.LoadAsset("myGame");
}
www.assetBundle.Unload (false);
}
yield return null;
}
And when I click on error it shows error on "www.assetbundle.Unload(false)" this line.
This is how I am instantiating my object after downloading
IEnumerator InstantiateLoadedAsset (Object objectName) {
var g = Instantiate (objectName, Vector3.zero, Quaternion.identity) as GameObject;
yield return null;
}
can anybody tell me whats wrong with my code
Answer by Graham-Dunnett · Jun 23, 2015 at 01:10 PM
The documentation example for WWW.LoadFromCacheOrDownload()
shows the code waiting for the download to finish before it does anything with the WWW
. I assume trying to unload assets that haven't even loaded yet is the problem.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Making a bubble level (not a game but work tool) 1 Answer
Spikes for a platformer game 1 Answer
Clear Does not work to remove 1 Answer