如何在Andy Prefab上的ARCore中使用AssetBundled 3D资产

时间:2018-07-20 13:05:43

标签: unity3d arcore assetbundle

我为自己的3D资产之一创建了资产捆绑包,并且还通过在运行时下载该捆绑包的正常工作进行了测试。现在,我希望在ARCore中执行相同的资产捆绑过程。我不想从外部服务器上将Andy 3D资产加载为预制件,而是加载为AssetBundle。 而且我在ARCore中尝试过AssetBundling,但无法正常工作。

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//using UnityEditor;

public class DownloadAssetBundle : MonoBehaviour {
    public static DownloadAssetBundle instance = null;
    [HideInInspector]public string url;
    [HideInInspector]public GameObject assetDemo;
    // Use this for initialization
    void Awake()
    {
        if (instance == null)


            instance = this;


        else if (instance != this)

            Destroy(gameObject);
    }
    void Start () {
        url = "https://s3.amazonaws.com/bucketname/myasset";
        StartCoroutine (DownloadAsset());
    }

    IEnumerator DownloadAsset()
    {
        WWW www = new WWW (url);
        yield return www;
        AssetBundle assetbundle = www.assetBundle;
            assetDemo = (GameObject)assetbundle.LoadAsset ("DinningTable");
            //Instantiate (assetDemo,Vector3.zero,Quaternion.identity);

    }
}

通过使用上面的代码,我从AWS S3存储桶中下载AssetBundle,并且我还为此脚本创建了实例,因为我想在ExampleController中实例化“ assetDemo”变量gameobject,我也这样做了

andyObject = Instantiate(DownloadAssetBundle.instance.assetDemo, hit.Pose.position, hit.Pose.rotation);

但是它不起作用!!!有人可以帮我吗

0 个答案:

没有答案