Load a 3d model from firebase storage using API to WebGL project
I am trying to load a 3d model from my firebase storage using regular API get call. In editor mode the following error is thrown:
Error while downloading Asset Bundle: Failed to decompress data for the AssetBundle 'https://console.firebase.google.com/u/1/project/example1/storage/example1.appspot.com/ring2'.
using System.Collections; using UnityEngine; using UnityEngine.Networking; using UnityEngine.UI;
public class LoadAsset : MonoBehaviour {
public Text loadingText;
string endPoint = "https://console.firebase.google.com/u/1/project/example1/storage/example1.appspot.com";
string modelToLoad= "ring2";
void Start()
{
StartCoroutine(GetAssetBundle());
}
IEnumerator GetAssetBundle()
{
var www = UnityWebRequestAssetBundle.GetAssetBundle(endPoint + "/" + modelToLoad);
yield return www.SendWebRequest();
AssetBundle assetBundle = DownloadHandlerAssetBundle.GetContent(www);
Debug.Log("assetBundle: " + assetBundle);
if (www.result != UnityWebRequest.Result.Success)
{
Debug.Log(www.error);
loadingText.text = www.error;
}
else
{
Debug.Log("success !");
loadingText.text = "success !";
AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(www);
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Saving data with files 1 Answer
,Call api and wait answer to return (async?) 1 Answer
Best data type for storing large quantities of data? 0 Answers
Web Game Database 1 Answer