Live update addon let you update database data on player's devices using the data from Google Sheets, using public GoogleSheets Json API. Export to google sheets is not supported.
- WebGl platform requires special setup (read below)
- Do not use this addon to update critical data. There is a chance some users won't be able to download updates (due to network issues for example).
- Plugin uses formatted values, not raw value. If you use numeric fields, please, make sure formatted value for these fields are the same as raw values (you may need to change cells formatting)
|DataSource type->||GoogleSheets API||Visualization API||Excel file export|
|URL to retrieve data||https://sheets.googleapis.com/v4/spreadsheets/[Your Spreadsheet Id]/values/[Table Name]?key=[Your API key]||https://docs.google.com/spreadsheets/d/[Your Spreadsheet Id]/gviz/tq?tqx=out:csv&sheet=[Table Name]||https://docs.google.com/spreadsheets/d/[Your Spreadsheet Id]/export|
|Number of network calls||1 * number of tables||1 * number of tables||1|
|Pros||Official recommended method||Do not require any credentials||
How it works
- First time your game is launched and database is loaded, it'll try to read data from Google Sheets. Alternatively set "Manual load" parameter on and trigger loading manually from script at any moment
- If step 1 is successful, every time database is loaded, it will be merged with data from Google Sheets, thus applying the update.
- If step 1 is unsuccessful, database data will remain intact.
- Enable LiveUpdate plugin (under addons->LiveUpdate)
- Choose DataSource type (GoogleSheets API/Visualization API/Excel file export)
- Get Spreadsheet Id from Google. Assign it to Spreadsheet Id LiveUpdate addon parameter
- If you chose GoogleSheets API, get "API key" from Google. Assign it to API key LiveUpdate addon parameter
- Make sure to share target spreadsheet. Open target spreadsheet, click on Share button on the top right and set access level to "public" or "people with link". Otherwise plugin won't work.
Google sheets data should have proper layout (as described here).
_idcolumn with valid IDs is required.
Checking if setup was correct
[BGDatabase version >=1.5.2 is required] WEBGL platform does not allow to update data synchronously. So it updates data asynchronously, over several frames. It means data should be preloaded before it can be accessed. Alternative way to load data asynchronously is to toggle on "Force asynchronous" parameter.
Here are the required steps:
- Make sure to toggle "Manual Load" parameter on
- Download this preloader script and attach it to any GameObject in your starting scene
- Once LiveUpdate plugin finishes downloading data, LiveUpdatePreloader.Ready method will be called. Make sure to not access database until this moment
- Preloader should work on any platform, no need to write platform specific code
|Spreadsheet Id||Id of your spreadsheet. Learn how to obtain it here|
|API key||API key to use for GoogleSheets API datasource type. Learn how to create it here|
|Timeout||Timeout for connection. Value (in seconds) is between 1-30, default is 5|
Set it to true if you do not want this addon to be executed automatically.
In this case, you will need to manually trigger the loading by calling
|In Builds Only||Setting this to true will disable addon if your game is run in Editor. It will work in builds only. It is recommended to set it to true as soon as you are sure the addon works correctly.|
|Force asynchronous||If set to true, data loader will use asynchronous loader, which does not block main thread and loads data over several frames. WEBGl platform ignores this parameter, cause it does not support synchronous loader and uses asynchronous loader by default|
|Merge Settings||The same merge settings you use for Export/Import or Saving/Loading. Learn more about merge settings here|
|Log level||level of details to be used while gathering log information. Logs messages are gathered while addon tries to read information from GoogleSheets|
|Print log on load||If set to true, log will be printed to Unity console after load attempt|
|Value resolver type||Full C# type name to be used to convert GoogleSheets values to another format. This type should implement BansheeGz.BGDatabase.BGLiveUpdateValueResolver interface. For example, you could use currency formatted values inside GoogleSheet for int fields ($5,200). To properly read such values you need to convert them to valid int values ($5,200->5200). Here is an example implementation of such type, which do such conversion.|