how to utilise firebase asset download method in addressables?
Hello,
I am using Addressable package and Firebase Storage for my Unity Project. Firebase has given below code in their docs to generate downloadURL for assets stored in Firebase Storage.
// Create a reference from a Google Cloud Storage URI Firebase.Storage.StorageReference reference = storage.GetReferenceFromUrl("gs://bucket/images/stars.jpg");
// Fetch the download URL reference.GetDownloadUrlAsync().ContinueWith((Task task) => { if (!task.IsFaulted && !task.IsCanceled) { Debug.Log("Download URL: " + task.Result()); // ... now download the file via WWW or UnityWebRequest. } });
So in the case of Adressables, I need to set Remote Load Path as "gs://bucket/images/stars.jpg". while execution , this will throw an error simply because its not a direct downloadURL. My question is where and how do I integrate this code in Addressables system? Thanks in Advance!!
Answer by NadzMiheisi · Jun 23, 2020 at 03:28 PM
Implement the following method before loading anything:
public static string FirebaseLoadPath;
private void GetDownloadURL()
{
var fireBaseRef = FirebaseStorage.DefaultInstance.GetReferenceFromUrl("gs://[your google bucket reference]");
fireBaseRef.GetDownloadUrlAsync().ContinueWith((Task<Uri> task) =>
{
if (!task.IsFaulted && !task.IsCanceled)
{
FirebaseLoadPath = task.Result.ToString();
}
});
}
Then use this as you remote load path {[YourClassName].FirebaseLoadPath}. And make sure you there is a check in place so nothing is loaded before the url is set.
Your answer
Follow this Question
Related Questions
Getting Real World Map Data 0 Answers
Can't run Local Asset Bundle Server 1 Answer
How to divide full-sized game in packages and download them during runtime? 1 Answer
How to remove old and unnecessary addressables assetpacks from the device 1 Answer
Why do asset bundles have so many build targets if some are compatible? 0 Answers