AssetBundle.LoadAsync を使用して Assets フォルダーからプレハブを直接読み込むことはできますか? Assets/Bundle フォルダーには "BGELement" というプレハブがあります。それを Resources フォルダーに入れず、Resource.Load を使用してロードしたくありませんでした。以下は私のコードですが、エラーが発生します: NullReferenceException、エラー行は ab.LoadAsync() です
using UnityEngine;
using System.Collections;
public class Test : MonoBehaviour {
void Start () {
StartCoroutine(NewLoadBGElement ());
}
IEnumerator NewLoadBGElement () {
string path = Application.dataPath + "/Bundle/BGElement";
AssetBundle ab = new AssetBundle ();
AssetBundleRequest abr = ab.LoadAsync(path, typeof(GameObject));
yield return abr;
GameObject newCube = Instantiate(abr.asset) as GameObject;
}
}