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;)
Simple Code:
using System.Collections.Generic;
using UnityEngine;
using SIDGIN.GoogleSheets;
using SIDGIN.Common;
[CreateAssetMenu(fileName = "ActorsData", menuName = "Test/ActorsData")]
[GoogleSheet("ActorsTable","Actors")]
public class ActorsData : ScriptableObject, ICollectionSet<ActorData>
{
[SerializeField]
List<ActorData> actors;
void ICollectionSet<ActorData>.SetCollection(List<ActorData> data)
{
actors = data;
}
}
[System.Serializable]
public class ActorData
{
[SerializeField, GoogleSheetParam("id")]
string id;
[SerializeField, GoogleSheetParam("daily_income")]
int dailyIncome;
[SerializeField, GoogleSheetParam("test_bool")]
bool testBool;
[SerializeField, GoogleSheetParam("speed")]
float speed;
[SerializeField, GoogleSheetParam("weapons")]
List<string> weapons;
}
Hello!!! I have questions:
- Will the data be updated before “Resources.Load<>…”?
- I suppose there is a limited list of types that you can convert? Is it possible to create my converters?
Thank you.
1 Like
Hello! Thank you for reply.
- Yes, sure.
- You can create your own converter. For example:
class CountDataConverter : IValueConverter
{
public Type Type => typeof(List<CountData>);
public object Convert(string input, Type type)
{
var pairs = input.Split(',');
if (pairs != null && pairs.Length > 0)
{
var result = new List<CountData>();
foreach (var item in pairs)
{
var s = item.Split(':');
if (s.Length == 2)
{
try
{
result.Add(new CountData
{
key = s[0],
count = int.Parse(s[1])
});
}
catch { }
}
}
if (result.Count > 0)
return result;
else
return null;
}
return null;
}
}
Google Sheets released!!! Check [link](http:// Google Sheets | Integration | Unity Asset Store).
Hi, is any possible to add a new record to google sheet?
Can this be used on iOS device? Does it handle OAuth2 portal?
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 ?
Same, did you find a solution?