Crave For Games


The text below is one of the notes from the StoneDrop development log. If you want a list of only technical articles you can go to the Articles page.
Import from Google SpreadSheets to Unity3d

151219_examples.png

Spreadsheets with configuration data examples

Configuration data import occurs only in Unity editor. For the import process I use the library GData.dll and the written class (available in the attached Unity-package) with convenient methods of authorization and import from the Spreadsheets.

 

Before the first import, the Google-service has to be created and access-to-SpreadSheets-data permission has to be granted.

 

The service creation process is the following (details are in Readme.txt of Unity-package):

1. Activate Drive API in Google Developers Console of your account;

2. Customize settings (name, icon) of a created service;

3. Create new credentials (OAuth client ID) and receive the Client ID and Client Secret.

The process of initial access permission to Google SpreadSheets data is following:

1. Save previously obtained <Client ID and Client Secret in the configuration file;

2. Start GSS Import/Setup and copy the access key in the configuration file;

3. Start GSS Import/Setup.

The credentials from these steps are used in all following data imports, no authorization is required later. Class SpreadsheetImporter has a static method GetCells that returns a two-dimensional array of the cell values in the string format for a given SpreadSheet name, tab name and range of cells.

 

To store the imported data the objects serialization is used (details are in the upcoming post) where the data fill the fields of the serialized object(s). A special static class with static methods (that are runnable by pressing the corresponding menu item in the editor) converts imported arrays of strings to these objects (figure 1).

151219_code.png

Figure 1. Usage example of SpreadsheetImporter

 

Download link for the unity-package: drive.google.com/f...[1], it was tested in Unity 5.2 and 5.3.

 

Link 1: https://drive.google.com/file/d/0B_XUafEg3LvCWXlPNmtxWnc1d3c/view

This article in social networks: