我无法从Assest包中将资产作为Gameobject加载。它正在返回空。
yield return www;
AssetBundle bundle = www.assetBundle;
if (www.error == null)
{
GameObject tv = (GameObject)bundle.LoadAsset("tv");
//yield return tv;
//GameObject santaasset = Instantiate(bundle.LoadAsset("tv", typeof(GameObject)) as GameObject);
Debug.Log(bundle); // returns tv
Debug.Log(tv);//return null
Instantiate(tv);
}
else
{
Debug.Log(www.error);
}

更新:以前

之后

发布于 2018-05-18 12:04:23
AssetBundle.LoadAsset返回null,因为在要加载的AssetBundle中没有一个名为"tv“的对象。
1.Make确保拼写正确,或者将正确的对象传递给LoadAsset函数。这是区分大小写的。
2.You必须确保在构建AssetBundle之前将对象"tv“添加到AssetBundle中。
假设您的AssetBundle的名称是"house",要添加到它的对象是"tv",选择"tv"对象并将AssetBundle选项更改为"house"。如需参考,请参阅下图:

在您的例子中,问题是#1。AssetBundle的名称是"tv",您希望加载一个名为"1.obj"的对象。将"1"传递给LoadAsset函数,而不是"tv"。
https://stackoverflow.com/questions/50409140
复制相似问题