I'm loading asset bundle to Image target (vuforia) and it's working with small stuff like cubes etc. But I have problem with loading bigger AssetBundle.
using UnityEngine;
using System.Collections;
using System;
public class loadAsset1 : MonoBehaviour {
void Start () {
WWW www = new WWW("file:///Users/ewasniecinska/Desktop/bus");
//Debug.Log (www.data);
StartCoroutine(WaitForReq(www));
}
IEnumerator WaitForReq(WWW www)
{
while (!Caching.ready)
yield return null;
yield return www;
AssetBundle bundle = www.assetBundle;
if(www.error == null || www.error == "")
{
GameObject trump = (GameObject)bundle.LoadAsset("bus");
Instantiate (trump, new Vector3 (0, 0, 0), Quaternion.identity);
Debug.Log ("Received from Web: " + trump.gameObject);
}
else{
Debug.Log(www.error);
}
}
}
But when I try to load bigger assets. I got error like this, I think that sricpt doesn't wait for asset to load, but I'm not 100% sure about that.
ArgumentException: The Object you want to instantiate is null.
UnityEngine.Object.CheckNullArgument (System.Object arg, System.String message) (at /Users/builduser/buildslave/unity/build/Runtime/Export/UnityEngineObject.cs:238)
UnityEngine.Object.Instantiate (UnityEngine.Object original, Vector3 position, Quaternion rotation) (at /Users/builduser/buildslave/unity/build/Runtime/Export/UnityEngineObject.cs:150)
UnityEngine.Object.Instantiate[GameObject] (UnityEngine.GameObject original, Vector3 position, Quaternion rotation) (at /Users/builduser/buildslave/unity/build/Runtime/Export/UnityEngineObject.cs:205)
loadAsset1+<WaitForReq>c__Iterator0.MoveNext () (at Assets/loadAsset1.cs:28)
UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at /Users/builduser/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)
Please check asset name "bus" is correct or not. i got same error because of incorrect asset name.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.