Giter Site home page Giter Site logo

googlesheetprovider's Introduction

Create Google Sheet Reader

3. Get service account key

  • Click on just created service account under Service accounts tab.
  • Go to Keys tab.
  • Click Add key->Create New key.
  • Select Json (default).
  • Click Create.
  • Rename downloaded file to "client_secret.json"
  • Place it in your project in Resources folder

4. Add Service Account to Google Sheets

Copy service account mail under Service Accounts tab. Add created service account to your GoogleSheets table

5. Import GoogleSheetReader package

Just import package to unity. If you already using Newtonsoft in your project ignore folder "Newtonsoft.Json " while importing

I recomended to upgrade unity builtin Newtonsoft package by adding "com.unity.nuget.newtonsoft-json": "3.0.2" to you manifest file under Packages folder. Version must be 3.+

6. Fill Package variables

Get google sheet id from link https:/docs.google.com/spreadsheets/d/1g***********************/edit#gid=1162944446 Add early downloaded client_secret.json

Create minimum one table script using data from google sheet

  [SpreadSheet("Squad")]
  [Serializable] public class SquadData : ISheetData
  {
      public string sID;
      public string uID;
      public int level;
      public float exp;
      public int unitCount;
  }

"Squad" it is name of table in google sheets

Click "Create sheets SO" and "Load Data" in package settings

7. Create provider script

To access google sheets data required to create provider script using just autocreated ConfigDatabase.cs

    public class ConfigDataProvider : SpreadSheetsDataProvider<ConfigDatabase>
    {

    }

8. All done


Functionality

  • Create sheets SO - need to be click after adding each new data table. Add new data table to ConfigDatabase

  • Load data - manual load latest data from google sheets base on created data tables. After success loading automatically save data into binary file;

  • Save to file - manually save ConfigDatabase to binary file. Can be used after manual changing some values in ConfigDatabase to apply changes into binary

  • Clear all saves - yes your right it just clear all saved binary files

  • Json - #TODO remove from screenshots

Data Access

  private ConfigDataProvider _configDataProvider;
  ...
  var values=_configDataProvider.Database.GetSpreadSheetData<SquadData>();
  foreach (var squadData in values)
  {
      Debug.Log(squadData.ToString());
  }

Output

s1 u1 0 100 3
s2 u1 1 200 5

googlesheetprovider's People

Contributors

redpenguine avatar nikitamironenkourmobi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.