Home > other >  From web pages load AssetBundle, how to save locally, unity novice, strives for the bosses give dire
From web pages load AssetBundle, how to save locally, unity novice, strives for the bosses give dire

Time:09-27

IEnumerator LoadGameObject (url string, the string objName)
{
The Debug Log (" ready to download AB ");
UnityWebRequest UnityWebRequest=UnityWebRequestAssetBundle. GetAssetBundle (url);
Yield return unityWebRequest. SendWebRequest ();
AssetBundle ab=DownloadHandlerAssetBundle. GetContent (unityWebRequest);
GameObject obj=ab. LoadAsset (objName);
Instantiate (obj);
The Debug Log (" download AB finish ");
}

CodePudding user response:

 IEnumerator LoadGameObject (url string, the string objName) 
{
The Debug Log (" ready to download AB ");
UnityWebRequest UnityWebRequest=UnityWebRequestAssetBundle. GetAssetBundle (url);
Yield return unityWebRequest. SendWebRequest ();

//save
System. IO. File. WriteAllBytes (" filename ", unityWebRequest. DownloadHandler. Data)

AssetBundle ab=DownloadHandlerAssetBundle. GetContent (unityWebRequest);
GameObject obj=ab. LoadAsset (objName);
Instantiate (obj);
The Debug Log (" download AB finish ");
}

CodePudding user response:

File. WriteAllBytes () method is an error: a NotSupportedException: Raw data access is not supported for asset bundles don't know is why?
  • Related