Google Sheets

Features

  1. Export/import data in Unity Editor (during game development) via this plugin
  2. Update database data on players devices at runtime from Google Sheets with LiveUpdate addon
  3. Currently, there is no way to write to Google Sheets at runtime from players devices (Why not?)

Additional guides

  1. Read this guide to learn how to create data sources and jobs
  2. Read this guide to learn about advanced settings, available for Google Sheets
  3. Read this guide to learn how to transfer tables/fields from Google Sheets

Setup

Step 1 : Import Google sheets plugin

Import this plugin.

Step 2 : Create Google Sheets DataSource

Open BGDatabase window Window->BGDatabase

Select Export/import tab, then "Data sources" tab, press plus icon, choose Datasource type to be GoogleSheets and click Add button

[Important]: Keep your settings file private if you use GoogleSheets. Do not share it with anyone

Step 3 : Setting up Google Sheets DataSource
Setting up Google Sheets DataSource depends on authentication type. Choose authentication type and read setup guide for this type.
OAuth 2.0 (default) Service API Key Anonymous
Access Read/Write to all spreadsheets Read/Write to all spreadsheets Read-only to public/shared spreadsheets Read-only to public/shared spreadsheets. No access to input value
Additional details This is recommended method It requires service email to be added to authorized users list for a chosen spreadsheet Easy to set up, but
1) readonly
2) requires spreadsheet to be shared or public
Easiest to set up, no need for any credentials, but
1) readonly
2) requires spreadsheet to be shared or public
3) no access to raw/input value
Setup guide read read read read
Step 4 : Create Export/Import task

Select Export/Import tab, press plus icon, choose Job type to be GoogleSheets and click Add button

Choose GoogleSheets datasource, created above. Set up metas (tables) you wish to update.

Running Export/Import Task

Press Export or Import button to run the task you created.

[Optionally] After job is finished, open Log tab to see full log of all actions performed. Pay attention to Warning messages (colored red). Every error or unexpected event happened during syncing will be colored red.

Target empty spreadsheet while exporting for the first time. Export job will create necessary sheets/header rows + data for you (more information)

Make sure you have as many physical rows/columns as you need, delete empty rows/columns to boost performance.

Google sheets localization

Starting with plugin version 1.8 and BGDatabase v.1.8.7 all new data sources by default uses spreadsheet locale (which can be found under "File->Settings") for parsing/constructing floating point numbers (which are passed as strings by GoogleSheets API). Data source locale can be changed under Datasource->Misc

Using Google sheets as shared remote database

You can use Google Sheets as remote shared database to be used by several developers (during game development)

Starting with version 1.5.4, we enforce locking mechanism to ensure only one export job is running at a time to avoid possible data collision. We use separate sheet (_dblock_) with one single cell (A1) to hold the lock value. Unfortunately this mechanism is not 100% solid and there is still a tiny chance 2 export jobs run at the same time - in this case you will get a warning message after the export. If you see this warning - review GoogleSheets data to make sure everything is ok and export data one more time if there is any issue.

GoogleSheets and empty rows

Unlike Excel exporter, GoogleSheets exporter does not try to use the empty rows. If you have empty rows in your sheet - they will be omitted.

If you do not need these empty rows - select them and delete

Why you do not provide an option to update GoogleSheets data from player devices?

TLDR: Our export procedure is not meant to be executed simultaneously by multiple clients. If your app/game is running on a single device or if only one device can export data to GoogleSheets, you can use this plug-in

DETAILED EXPLANATION: To update data we need to read and analyse it first to determine which cells need to be updated and also optionally resize the sheet. Reading, analysing and updating data are not atomic operation. If somebody else updates the data during reading/analysis - writing data may result in data corruption/errors.

This problem can be solved with a proxy server, but it also means there is no need for direct access to GoogleSheets.

If you are still looking for a way to write data to GoogleSheets from players devices:

  1. If all you need is to add data to spreadsheet, you can use Google Forms, linked to a spreadsheet and HTTP POST to add data to spreadsheet. Also, read our mini tutorial, how to use Google Forms to update GoogleSheets here
  2. If you need more sophisticated control GoogleSheets dotnet API library v4 is probably the best starting point.