I successfully load 2D assetbundle from server on iOS, android, editor. Everything is going well when I load 3D model in android and Editor.
But it fails when load 3D model for iOS.
I have separated build asset for iOS and Android.
here is my method, and :
IEnumerator downloadAsset(BaseModel baseModel){
string url = baseModel.url_android;
#if UNITY_IOS
url = baseModel.url_ios;
#endif
WWW download = new WWW(url);
progressBar.SetActive (true);
progressItem.anchorMax = new Vector2 (0, 1f);
while (download.progress < 1 && download.error == null) {
yield return new WaitForSeconds(2f);
progressItem.anchorMax = new Vector2 (download.progress,1f);
}
progressBar.SetActive (false);
yield return download;
AssetBundle assetBundle = download.assetBundle;
if (assetBundle != null) {
// Alternatively you can also load an asset by name (assetBundle.Load("my asset name"))
m2DPrefab = assetBundle.LoadAsset(baseModel.title) as GameObject; //iOS force stop here
Debug.Log("Prefab created");
if (m2DPrefab != null) {
InstantiateModel (m2DPrefab, baseModel.title);
//StartCoroutine(SetBackground(baseModel.url_background));
model.SetActive (true);
} else
Debug.Log("Couldn't load resource");
} else {
Debug.Log("Couldn't load resource");
}
}
Note : I can load 3D asset bundle after I create model on the scene before I deploy it to iOS, then load asset bundle with that code. It works smoothly. But.. I want make it dynamic without instantiate it first.
I don't know how to fix it.
Please help.
Thanks
↧