コード例 #1
0
        private static void RetrieveGoogleAccessToken()
        {
            if (!webRequestObj.isDone)
            {
                return;
            }
            EditorApplication.update -= RetrieveGoogleAccessToken;

            waitingForGoogleAuthenticationToken = false;
            //If invalid response...
            if (webRequestObj.isHttpError || webRequestObj.responseCode != 200)
            {
                Debug.LogError($"[GoogleDataDownloader] Unable to get a new Google Drive access token. Try again or contact Tech/QA. {webRequestObj.downloadHandler.text}");
                return;
            }

            Debug.Log("[GoogleDataDownloader] Received Google OAuth2 access token!");
            googleDriveAccessToken            = GoogleDataUploader.ReplaceEscapeCharacters(webRequestObj.downloadHandler.text, true);
            googleAuthenticationTokenReceived = true;
            if (sendOutFirstFolderFetch)
            {
                sendOutFirstFolderFetch = false;
                RequestGoogleDriveFolderItems(defaultGoogleSharedDriveId, defaultGoogleDriveStartFolderId, defaultGoogleDriveStartFolderName);
            }
        }
コード例 #2
0
        private static void FetchGoogleDriveFolderItemsResults()
        {
            if (!webRequestObj.isDone)
            {
                return;
            }
            EditorApplication.update -= FetchGoogleDriveFolderItemsResults;

            //Handle unexpected error
            if (webRequestObj.isHttpError || webRequestObj.responseCode != 200)
            {
                googleFolderIdHierarcyTree.RemoveAt(googleFolderIdHierarcyTree.Count - 1);
                Debug.LogError($"[GoogleDataUpload] Unable to Fetch Google Drive folder Items.{webRequestObj.downloadHandler.text}");
                return;
            }

            //Remove certain characters from returned string ot be able to parse the string using JsonUtility
            string escapedResultFromJson = GoogleDataUploader.ReplaceEscapeCharacters(webRequestObj.downloadHandler.text);
            GoogleDriveSearchResults returnedFolderResults = JsonUtility.FromJson <GoogleDriveSearchResults>(escapedResultFromJson);

            CleanupGoogleItemStruct(ref returnedFolderResults);   //Process returned struct for future use

            //Either set the currentSearch to display or add to a queue for download
            currentGoogleSearch = returnedFolderResults;
            if (downloadingRecursively)
            {
                PrepareDownloadCurrentItems();
            }
        }
コード例 #3
0
 public void Awake()
 {
     instance = this;
 }