MokaGames / Unity-QuickSheet

Unity-QuickSheet enables you to use spreadsheet file data within Unity editor.
http://kimsama.github.io/Unity-QuickSheet
MIT License
5 stars 5 forks source link

Data is not correctly downloaded from Google when the table's header is in the form of 'Name | string' #1

Open zzxiang opened 6 years ago

zzxiang commented 6 years ago

The problem occurs when clicking the "Download" button. The number of entries in the table is correctly recognized, but all the entries are null.

zzxiang commented 5 years ago

The download procedure is implemented in the Load method in ScriptableObjectEditorClass.txt. The Load method calls GDataDB.Impl.GetTable<T> method written in Database.cs.

Maybe the Google Data API Client Library being used is outdated. The new library seems to be:

https://github.com/googleapis/google-api-dotnet-client https://developers.google.com/api-client-library/dotnet/apis/sheets/v4 https://developers.google.com/sheets/

zzxiang commented 5 years ago

Seems that the reason lies in the Deserialize method of class GDataDB.Impl.Serializer<T> in GDataPlugin\Editor\GDataDB\GDataDB\Impl\Serializer.cs.

        public T Deserialize(ListEntry e) {
            var t = typeof (T);
            var r = (T) Activator.CreateInstance(t);
            foreach (ListEntry.Custom c in e.Elements) {
                var property = t.GetProperty(c.LocalName, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Public);
                if (property == null)
                    continue;
                    ...

Say I have a spreadsheet column with header 'id | string'. Then c.LocalName is expected to be 'id'. But actually its value is 'idstring', so that the resulted property got is null.

See https://developers.google.com/sheets/api/v3/data

If the header cell's content contains a space or other non-alphanumeric character, it will be removed in the gsx element name.