I am creating an augmented reality app using vuforia and unity. i have uploaded my assetbundle to firebase storage and i want to retrieve a 3d model saved inside it and load it as a child on my image target game object.to check this i tried to load a 3d model as a child of the main camera.but it i cant retrieve it.i also installed firebase unity sdk.
using Firebase.Storage;
using System.Threading.Tasks;
using System.Collections;
using UnityEngine;
using System;
using UnityEngine.Networking;
public class Loadmodel2 : MonoBehaviour
{
// Start is called before the first frame update
public GameObject test;
void Start()
{
FirebaseStorage storage = FirebaseStorage.DefaultInstance;
Firebase.Storage.StorageReference reference =
storage.GetReferenceFromUrl("gs://fit-union-221609.appspot.com/assettest1/myasset");
reference.GetDownloadUrlAsync().ContinueWith((Task task) => {
if (!task.IsFaulted && !task.IsCanceled)
{
Debug.Log("Download URL: " + task.Result);
// ... now download the file via WWW or UnityWebRequest.
StartCoroutine(Loadcoroutine(task.Result));
}
});
}
IEnumerator Loadcoroutine(Uri uri)
{
using (var www = UnityWebRequestAssetBundle.GetAssetBundle(uri))
{
yield return www.SendWebRequest();
if (www.isNetworkError || www.isHttpError)
{
Debug.Log(www.error);
}
else
{
AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(www);
var mya1 = bundle.LoadAssetAsync("BarbarianVariant");
yield return mya1;
var obj = Instantiate((GameObject)mya1.asset);
obj.transform.parent = test.transform;
}
}
}
}
![alt text][1]
[1]: /storage/temp/149058-screenshot-8.png
↧