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
↧