Hi there,
It seems my asset bundles have stopped working in Unity5.5
I have some prefabs on my project, I set a common assetbundle name for them and exported them using this piece of code:
BuildPipeline.BuildAssetBundles(bundlePath, BuildAssetBundleOptions.None, BuildTarget.Android);
(BTW, it’s an android only game)
When I instantiate the asset, it has no rigidbody nor collider attached, its just a plain gameObject. Any clue?
This is the code I use to instantiate them…
using (WWW www = WWW.LoadFromCacheOrDownload(url, version))
{
float timer = 0;
bool failed = false;
while (!www.isDone)
{
if (timer > timeOut) { failed = true; break; }
timer += Time.deltaTime;
yield return null;
}
if (failed)
{
//TODO: show error popup
Debug.LogError("WWW download timeout!");
SceneManager.LoadScene("MainMenu");
Destroy(this.gameObject);
}
if (www.error != null)
{
//TODO: show error popup
Debug.LogError("WWW download had an error:" + www.error);
Destroy(this.gameObject);
}
// Load and retrieve the AssetBundle
AssetBundle bundle = www.assetBundle;
// Load the object asynchronously
AssetBundleRequest request = bundle.LoadAssetAsync(asset, typeof(GameObject));
// Wait for completion
yield return request;
// Get the reference to the loaded object
GameObject InstanceObj = request.asset as GameObject;
//instantiate this asset
GameObject newInstance = (GameObject)Instantiate(InstanceObj) as GameObject;
}
bundle.Unload(false);
} // memory is freed from the web stream (www.Dispose() gets called implicitly)
Thank you very much!