IEnumerator LoadGameObject(string url,string objName)
{
Debug.Log("準備下載AB");
UnityWebRequest unityWebRequest = UnityWebRequestAssetBundle.GetAssetBundle(url);
yield return unityWebRequest.SendWebRequest();
AssetBundle ab = DownloadHandlerAssetBundle.GetContent(unityWebRequest);
GameObject obj = ab.LoadAsset<GameObject>(objName);
Instantiate(obj);
Debug.Log("下載AB完成");
}
uj5u.com熱心網友回復:
IEnumerator LoadGameObject(string url, string objName)
{
Debug.Log("準備下載AB");
UnityWebRequest unityWebRequest = UnityWebRequestAssetBundle.GetAssetBundle(url);
yield return unityWebRequest.SendWebRequest();
// 保存
System.IO.File.WriteAllBytes("filename", unityWebRequest.downloadHandler.data)
AssetBundle ab = DownloadHandlerAssetBundle.GetContent(unityWebRequest);
GameObject obj = ab.LoadAsset<GameObject>(objName);
Instantiate(obj);
Debug.Log("下載AB完成");
}
uj5u.com熱心網友回復:
File.WriteAllBytes()方法報錯:NotSupportedException: Raw data access is not supported for asset bundles不知道是為何?轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/15615.html
標籤:Unity3D
