From e6621cdd8b0c6349b96d65d97f51e922a59515a1 Mon Sep 17 00:00:00 2001 From: kimsama Date: Tue, 9 Aug 2016 19:32:41 +0900 Subject: [PATCH] * Fixed the issue #19. Fixed updating on google machine setting file correctly update changes of the google spreadsheet(to correctly retrieve changed header columns). --- .../GDataPlugin/Editor/GoogleMachineEditor.cs | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/Assets/QuickSheet/GDataPlugin/Editor/GoogleMachineEditor.cs b/Assets/QuickSheet/GDataPlugin/Editor/GoogleMachineEditor.cs index 260b828..21f25e1 100644 --- a/Assets/QuickSheet/GDataPlugin/Editor/GoogleMachineEditor.cs +++ b/Assets/QuickSheet/GDataPlugin/Editor/GoogleMachineEditor.cs @@ -207,6 +207,9 @@ protected override void Import(bool reimport = false) else headerDic = machine.HeaderColumnList.ToDictionary(k => k.name); + List tmpColumnList = new List(); + + // query the first columns only. DoCellQuery((cell) => { @@ -217,19 +220,29 @@ protected override void Import(bool reimport = false) if (int.Parse(m.Value) > 1) return; - if (machine.HasHeadColumn() && reimport == false) + HeaderColumn column = new HeaderColumn(); + column.name = cell.Value; + if (headerDic != null && headerDic.ContainsKey(cell.Value)) { - if (headerDic != null && headerDic.ContainsKey(cell.Value)) - machine.HeaderColumnList.Add(new HeaderColumn { name = cell.Value, type = headerDic[cell.Value].type }); + // if the column is already exist, copy its name and type from the exist one. + HeaderColumn h = machine.HeaderColumnList.Find(x => x.name == column.name); + if (h != null) + { + column.type = h.type; + column.isArray = h.isArray; + } else - machine.HeaderColumnList.Add(new HeaderColumn { name = cell.Value, type = CellType.Undefined }); + column.type = CellType.Undefined; } else - { - machine.HeaderColumnList.Add(new HeaderColumn { name = cell.Value, type = CellType.Undefined }); - } + column.type = CellType.Undefined; + + tmpColumnList.Add(column); }); + // update (all of settings are reset when it reimports) + machine.HeaderColumnList = tmpColumnList; + EditorUtility.SetDirty(machine); AssetDatabase.SaveAssets(); }