protected void GrabPixelsOnPostRender(string fileName) { //Create a new texture with the width and height of the screen Texture2D texture = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false); //Read the pixels in the Rect starting at 0,0 and ending at the screen's width and height texture.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0, false); texture.Apply(); byte[] bytes = texture.EncodeToPNG(); string path = AssetsExporter.imagesStorageURL + fileName + ".png"; // Create a reference with an initial file path and name Firebase.Storage.StorageReference path_reference = storage.GetReference(path); // Upload the file to the path "images/rivers.jpg" path_reference.PutBytesAsync(bytes) .ContinueWith((Task <Firebase.Storage.StorageMetadata> task) => { if (task.IsFaulted || task.IsCanceled) { Debug.Log(task.Exception.ToString()); Debug.Log("task failed: " + path + " " + fileName); // Uh-oh, an error occurred! } if (task.IsCanceled) { Debug.Log("task was canceled"); } else { // Metadata contains file metadata such as size, content-type, and download URL. Firebase.Storage.StorageMetadata metadata = task.Result; //string download_url = metadata.DownloadUrl.ToString(); Debug.Log(fileName + " Finished uploading..."); progress += 1; // Fetch the download URL path_reference.GetDownloadUrlAsync().ContinueWith((Task <Uri> getURLtask) => { if (!getURLtask.IsFaulted && !getURLtask.IsCanceled) { AssetsExporter.modelsDict[fileName][AssetsExporter.modelDBImageKey][AssetsExporter.modelDBImageURLKey] = getURLtask.Result; } }); } }); }
void obtenerArchivo(string nombre, string extencion, string codigo) { Debug.Log("ARCHIVO BUSCADO: " + nombre + "&&" + codigo + "." + extencion); Firebase.Storage.FirebaseStorage storage = Firebase.Storage.FirebaseStorage.DefaultInstance; Firebase.Storage.StorageReference reference = storage.GetReference(nombre + "&&" + codigo + "." + extencion); reference.GetDownloadUrlAsync().ContinueWith((Task <Uri> linkDescarga) => { if (!linkDescarga.IsFaulted && !linkDescarga.IsCanceled) { StartCoroutine(descargar(linkDescarga.Result.ToString(), nombre, extencion, codigo)); } }); }