我为我的一个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);
但它没有工作!任何人都可以帮助我摆脱它