Skip to content

Unity Editor/Runtime Tools I have created related to interacting and uploading/downloading google drive items

License

Notifications You must be signed in to change notification settings

jesseroffel/Unity-GoogleDriveTools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unity Google Drive Tools

For the project Spellbound Spire we used Google Drive to store certain analytic data about a player. As this data was processed in a different tool and we needed per level all available analytic data I created these small scripts which can Upload files and an editor tool that can Download files.

The goal is to easily Upload any file and Download one or multiple files to or from the Google Drive quickly while developing using the Unity Engine.

NOTE: This project won't be updated anymore as the development on Spellbound Spire has stopped, this code should however still work when following the instructions below.

Set it up yourself

Both inside the GoogleDataUploader.cs and GoogleDataDownloader.cs files there are missing fields that need to be filled in before the tool can work.

Google Drive Setup

  • [DRIVEID] => (Shared)Drive Id as found in the url
  • [DRIVEROOTID] / [FOLDERSTARTID] => Optional starter Id of a folder within the Drive.

Both scripts make use of the Google Drive V3 API, which requires OAuth2 access tokens to be used for each web request.

Setup if required the access to the API services here: https://console.developers.google.com.

Google OAuth2 Access Token Setup

  • [REFRESH_TOKEN] => Google OAuth2 Refresh Token
  • [CLIENT_ID] => Google OAuth2 Client ID
  • [CLIENT_SECRET] => Google OAuth2 Client Secret

Uploading

Uploading is done with a singleton class GoogleDataUploader.cs which has to exist within an active scene to be access.

Using a single static call UploadLocalFileToGoogleDrive() it can upload a file asynchronously to the matching Google Drive Folder.

Currently the accepted files are binary, options can be set to create a separate folder based on the filename which we used to categorise per level, any upload can have a GUID attached to the file name to anonymously upload a file with an identification in place.

Downloading Editor Tool

Downloading can be done through an Unity engine editor tool class GoogleDataDownloader.cs, this tool will provide an basic Google Drive file directory viewer with download options and configuration settings.

A simple configuration screen and navigation allows for quick downloading of one or multiple files without much hassle.

Any file can be currently downloaded towards the target folder, downloading a current folder will download files recursively if set, including folders matching the Google Drive folder online.

Created for Spellbound Spire

Check out the project on my portfolio website: Spellbound Spire.

About

Unity Editor/Runtime Tools I have created related to interacting and uploading/downloading google drive items

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages