Search Unity

[Released] Google Sheets

Discussion in 'Assets and Asset Store' started by sidgincompany, Apr 4, 2020.

  1. sidgincompany

    sidgincompany

    Joined:
    Feb 18, 2020
    Posts:
    72
    I want to share with you my solution for working with Google Sheets. The system allows you to create mapping tables, data type is taken into account using prepared value converters. Please show the video and write your questions and opinion;)
     
  2. sidgincompany

    sidgincompany

    Joined:
    Feb 18, 2020
    Posts:
    72
    Simple Code:
    Code (CSharp):
    1. using System.Collections.Generic;
    2. using UnityEngine;
    3. using SIDGIN.GoogleSheets;
    4. using SIDGIN.Common;
    5.  
    6. [CreateAssetMenu(fileName = "ActorsData", menuName = "Test/ActorsData")]
    7. [GoogleSheet("ActorsTable","Actors")]
    8. public class ActorsData : ScriptableObject, ICollectionSet<ActorData>
    9. {
    10.     [SerializeField]
    11.     List<ActorData> actors;
    12.  
    13.     void ICollectionSet<ActorData>.SetCollection(List<ActorData> data)
    14.     {
    15.         actors = data;
    16.     }
    17. }
    18.  
    19. [System.Serializable]
    20. public class ActorData
    21. {
    22.     [SerializeField, GoogleSheetParam("id")]
    23.     string id;
    24.     [SerializeField, GoogleSheetParam("daily_income")]
    25.     int dailyIncome;
    26.     [SerializeField, GoogleSheetParam("test_bool")]
    27.     bool testBool;
    28.     [SerializeField, GoogleSheetParam("speed")]
    29.     float speed;
    30.     [SerializeField, GoogleSheetParam("weapons")]
    31.     List<string> weapons;
    32. }
    upload_2020-4-4_18-38-59.png
     
  3. luis_fyer

    luis_fyer

    Joined:
    Apr 2, 2020
    Posts:
    1
    Hello!!! I have questions:
    1. Will the data be updated before "Resources.Load<>...."?
    2. I suppose there is a limited list of types that you can convert? Is it possible to create my converters?
    Thank you.
     
    mihanocho likes this.
  4. sidgincompany

    sidgincompany

    Joined:
    Feb 18, 2020
    Posts:
    72
    Hello! Thank you for reply.
    1. Yes, sure.
    2. You can create your own converter. For example:
    Code (CSharp):
    1. class CountDataConverter : IValueConverter
    2.     {
    3.         public Type Type => typeof(List<CountData>);
    4.  
    5.         public object Convert(string input, Type type)
    6.         {
    7.             var pairs = input.Split(',');
    8.             if (pairs != null && pairs.Length > 0)
    9.             {
    10.                 var result = new List<CountData>();
    11.                 foreach (var item in pairs)
    12.                 {
    13.  
    14.                     var s = item.Split(':');
    15.                     if (s.Length == 2)
    16.                     {
    17.                         try
    18.                         {
    19.                             result.Add(new CountData
    20.                             {
    21.                                 key = s[0],
    22.                                 count = int.Parse(s[1])
    23.                             });
    24.                         }
    25.                         catch { }
    26.                     }
    27.                 }
    28.                 if (result.Count > 0)
    29.                     return result;
    30.                 else
    31.                     return null;
    32.             }
    33.             return null;
    34.         }
    35.     }
     
  5. sidgincompany

    sidgincompany

    Joined:
    Feb 18, 2020
    Posts:
    72
    Google Sheets released!!! Check link.
     
  6. anthsu_TW

    anthsu_TW

    Joined:
    Nov 14, 2017
    Posts:
    1
    Hi, is any possible to add a new record to google sheet?
     
  7. NinePinNoTap

    NinePinNoTap

    Joined:
    Dec 21, 2017
    Posts:
    1
    Can this be used on iOS device? Does it handle OAuth2 portal?
     
  8. boaz12345678

    boaz12345678

    Joined:
    Jul 18, 2020
    Posts:
    1
    I tried using Google.Apis package, but I couldn't import it so Unity will recognize it.
    The same thing happens here with SIDGIN. How can I make unity recognize it ?
     
  9. unity_i0JypQEvpU_GWQ

    unity_i0JypQEvpU_GWQ

    Joined:
    May 11, 2022
    Posts:
    11
    I upgraded to Unity 2022.2.2f1, and it's not working, I have constant error upload_2023-1-21_20-45-14.png
     
  10. Pure_hate

    Pure_hate

    Joined:
    Jun 17, 2015
    Posts:
    2
    Same, did you find a solution?