public IEnumerator Test005_FilesDownload() { var request = GoogleDriveFiles.Download(createdFileId); yield return(request.Send()); Assert.IsFalse(request.IsError); Assert.NotNull(request.ResponseData.Content); Assert.Greater(request.ResponseData.Content.Length, 0); }
void DownloadModel() { var path = Application.persistentDataPath + "/" + fileName.Replace(" ", ""); //EditorUtility.RevealInFinder(path); //first try to get the file by name try { using (var assetLoader = new AssetLoader()) { var ops = AssetLoaderOptions.CreateInstance(); //Creates the AssetLoaderOptions instance. //AssetLoaderOptions let you specify options to load your model. //(Optional) You can skip this object creation and it's parameter or pass null. //You can modify assetLoaderOptions before passing it to LoadFromFile method. You can check the AssetLoaderOptions API reference at: //https://ricardoreis.net/trilib/manual/html/class_tri_lib_1_1_asset_loader_options.html ops.UseOriginalPositionRotationAndScale = true; ops.Scale = 1 / 1000f; var wrapperGameObject = gameObject; //Sets the game object where your model will be loaded into. //(Optional) You can skip this object creation and it's parameter or pass null. var myGameObject = assetLoader.LoadFromFile(path, ops, wrapperGameObject); //Loads the model synchronously and stores the reference in myGameObject. //successful retreival of file if (myGameObject != null) { var ObjectToPlace = Instantiate(myGameObject); //After instantiating object kill UI GameObject.Find("Canvas").SetActive(false); //Assign variable to TapToPlace GameObject.Find("AR Session Origin").GetComponent <TapToPlace>().objectToPlace = ObjectToPlace; } } } catch { //if we don't get the file locally, we'll have to download it from the server request = GoogleDriveFiles.Download(fileId); //request = GoogleDriveFiles.Download(fileId, range.start >= 0 ? (RangeInt?)range : null); request.Send().OnDone += SetResult; } }
void Update() { if (fileStatus == EDownloadStatus.kDownloadRequested) { fileStatus = EDownloadStatus.kInProgress; GoogleDriveFiles.List().Send().OnDone += RefreshFileList; } if (fileStatus == EDownloadStatus.kFilesListRefreshed) { fileStatus = EDownloadStatus.kInProgress; keyfile = files[0]; GoogleDriveFiles.Download(keyfile.Id).Send().OnDone += DownloadFile; } if (hasChanges && !(textForWalls is null) && fileStatus == EDownloadStatus.kDownloaded) { UpdateFile(); } }
private IEnumerator RestoreFromGoogleDriveSaveFileWithName(GameObject loadObject) { var request = GoogleDriveFiles.List(); yield return(request.Send()); string saveFileId = ""; for (int i = 0; i < request.ResponseData.Files.Count; i++) { if (request.ResponseData.Files[i].Name == "PS_SaveData") { saveFileId = request.ResponseData.Files[i].Id; break; } } if (saveFileId == "") { loadObject.SetActive(false); StopCoroutine(RestoreFromGoogleDriveSaveFileWithName(loadObject)); } var request2 = GoogleDriveFiles.Download(saveFileId); yield return(request2.Send()); string destination = Application.persistentDataPath + "/SaveData.xml"; File.Delete(destination); File.WriteAllBytes(destination, request2.ResponseData.Content); saveData = Load(); for (int i = 0; i < dataCreationManager.folderHolder.childCount; i++) { Destroy(dataCreationManager.folderHolder.GetChild(i).gameObject); } SetLoadedSaveData(); loadObject.SetActive(false); StructureManager.instance.NewNotification("Restore Completed"); }
void MountPhase(GameObject go) { loading.SetActive(true); string id = ""; Fileids.TryGetValue(go, out id); if (string.IsNullOrEmpty(id)) { Debug.LogError("Houve um erro ao carregar o arquivo!"); return; } Assets.Scripts.DAL.BetaTesterContext.FileId = id; var phase = Assets.Scripts.DAL.BetaTesterContext.Phase.GetData().Single(x => x.FileId == Assets.Scripts.DAL.BetaTesterContext.FileId); phase.Played++; Assets.Scripts.DAL.BetaTesterContext.Phase.Update(phase); GoogleDriveFiles.Download(id).Send().OnDone += SetResult; }
private IEnumerator RestoreFromGoogleDriveSaveFileWithID(GameObject loadObject) { var request = GoogleDriveFiles.Download(saveData.googleDriveSaveFileId); yield return(request.Send()); string destination = Application.persistentDataPath + "/SaveData.xml"; File.Delete(destination); File.WriteAllBytes(destination, request.ResponseData.Content); saveData = Load(); for (int i = 0; i < dataCreationManager.folderHolder.childCount; i++) { Destroy(dataCreationManager.folderHolder.GetChild(i).gameObject); } SetLoadedSaveData(); loadObject.SetActive(false); StructureManager.instance.dataSavePanel.SetActive(false); StructureManager.instance.NewNotification("Restore Completed"); }
private void DownloadTexture() { request = GoogleDriveFiles.Download(fileId, range.start >= 0 ? (RangeInt?)range : null); request.Send().OnDone += SetResult; }
private void HandleImageMetaReceived(UnityGoogleDrive.Data.File file) { request = GoogleDriveFiles.Download(file); request.Send().OnDone += RenderImage; }