Hi,
I’m developing for the Oculus Quest (Android) I followed with succes this online youtube tutorial about using assetbundles using Unity 2018
In this tutorial it stores the bundles locally, in my case i want to download the assetbundle from google drive and instantiate the gameobject in the scene.
So i changed my code but when pressing play in the editor i get the following errors;
Error while downloading Asset Bundle: Failed to decompress data for the AssetBundle
NullReferenceException: Object reference not set to an instance of an object LoadAssetBundlesRemote2+d__2.MoveNext () (at Assets/Scripts/LoadAssetBundlesRemote2.cs:29)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Scripting/Coroutines.cs:17)
Here is what my code looks like. What do i need to change to get it working?
using UnityEngine;
using UnityEngine.Networking;
using System.Collections;
public class LoadAssetBundlesRemote2 : MonoBehaviour
{
public string assetName;
void Start()
{
StartCoroutine(DownloadAsset());
}
IEnumerator DownloadAsset()
{
using (UnityWebRequest uwr = UnityWebRequestAssetBundle.GetAssetBundle(" The correct private google drive url"))
{
yield return uwr.SendWebRequest();
if (uwr.isNetworkError || uwr.isHttpError)
{
Debug.Log(uwr.error);
}
else
{
// Get downloaded asset bundle
AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(uwr);
var prefab = bundle.LoadAsset(assetName);
Instantiate(prefab);
}
}
}
}
NullReferenceException: Object reference not set to an instance of an object
AssetManager+d__2.MoveNext () (at Assets/Scripts/AssetManager.cs:63)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <092936fdc0c1418db54a09908cfb1cd1>:0)
I get errors at line 16 and 28.
28 is understandable since the asset bundle itself was not downloaded. What am I doing wrong with the link? It’s a direct link to the manifest file.
This is not the correct URL to your asset bundle. This link gives me a Web Page that has a download button.
What you need is a direct link, meaning when you paste URL to browsers address bar, you should get a file download immediately, not a web page loaded.
malhardevasthali007 i resolved the problem by creating direct link of file and then convert the share settings by restricted to anyone on the internet …by right clicking>share on the file in google drive … …Pls try this …