Unity Google Drive

MIT
by Elringus

Google Drive SDK for Unity game engine

( Crawled a few seconds ago )
+

Download unitypackage

UnityGoogleDrive.unitypackage

Description

SDK for Google Drive providing API for listing, searching, creating, uploading, editing, copying, downloading and deleting files on the User's drive from within Unity game engine.

Works with Unity version 5.6 and higher. Supports all major target platforms (including WebGL).

Core runtime is .NET 2.0 Subset profile compatible; however full .NET 2.0 profile is required for Json.Net.Unity3D library to work correctly (used for API data serialization).

Setup

  • Import the package
  • GoogleDriveSettings.asset will be automatically created in Assets/UnityGoogleDrive/Resources; select it
  • Click Create Google Drive API app button; web-browser will open URL to setup the app
    • Select Create a new project and click continue
    • Click Go to credentials
    • Click Cancel
    • Select OAuth consent screen tab and enter required info; click Save
    • Return to Credentials tab and click Create credentials -> OAuth client ID
    • Select Web application for 'Application type', give your app a name and enter the following restrictions:
      • Authorised JavaScript origins: enter host names wich will serve WebGL builds; not required for platforms other than WebGL
      • Authorised redirect URIs:
        • Add redirect URI for local loopback requests: http://localhost
        • Add full URIs to the WebGL builds locations; not required for platforms other than WebGL
      • Final result may look like that
    • Click Save
    • Close the appeared popup and click Download JSON button to get the credentials json file
  • Return to Unity editor, open the settings (you can also access them via Edit -> Project Settings -> Google Drive Settings) and click Parse credentials JSON file; select the downloaded credentials json file

Examples

Listing files

GoogleDriveFiles.List().Send().OnDone += fileList => ...;

Uploading file

var file = new Data.File() { Name = "Image.png", Content = rawImageData, MimeType = "image/png" };
GoogleDriveFiles.Create(file).Send();

Downloading file

GoogleDriveFiles.Download(fileId).Send().OnDone += file => ...;

For more examples take a look at test scripts.