I use assetbundles to reduce the storage space
of the application. The problem is that when I download the model from the server and point the device’s camera at the marker, the model is not displayed. Although logically everything is correct. The script is attached below. What could be the mistake? And why the seemingly simple process doesn’t work.
AssetBundles are downloaded via the Start method when the scene is started. Unpacking. And then, I put the model in the child position for the marker.
It is important to understand that everything is downloaded and unpacked correctly and still the model is not displayed when the device recognizes the marker
public class Download : MonoBehaviour
{
private string bundleURL = "http://3d.seatroll.no/ios-app/cloudab.unity3d";
private int version = 0;
public GameObject d,e,b,c;
GameObject a;
AudioClip aud1;
private void Awake()
{
}
private void Start()
{
StartCoroutine(DownloadAndCache());
}
IEnumerator DownloadAndCache() {
while (!Caching.ready) {
yield return null;
}
var www = WWW.LoadFromCacheOrDownload(bundleURL, version);
yield return www;
if (!string.IsNullOrEmpty(www.error)) {
Debug.Log(www.error);
yield break;
}
Debug.Log("Бандл загружен!");
var assetBundle = www.assetBundle;
AssetBundleRequest req = assetBundle.LoadAllAssetsAsync();
yield return req;
if (req.isDone)
d.GetComponent<Text>().text = "RDY";
string prefabName = "Jotun";
var prefabRequest = assetBundle.LoadAssetAsync(prefabName, typeof(GameObject));
yield return prefabRequest;
var aud = assetBundle.LoadAssetAsync("рык9 (mp3cut.net) (1)", typeof(AudioClip));
yield return aud;
Debug.Log("Prefab распакован");
d.GetComponent<Text>().text = "Prefab распакован";
a = Instantiate(prefabRequest.asset as GameObject,b.transform);
aud1 = aud.asset as AudioClip;
a.GetComponent<AudioSource>().clip = aud1;
e.GetComponent<hideapear>().a = a;
a.transform.localPosition = new Vector3(-0.039f, 0.107f, -0.149f);
a.transform.rotation = new Quaternion(-51.271f, 99.98801f, 83.506f, 1);
a.transform.localScale = new Vector3(0.3109194f, 0.3109194f, 0.3109194f);
}
}
8144282–1057514–Download.cs (1.9 KB)