Skip to content

Commit

Permalink
* Fixed the issue kimsama#19. Fixed updating on google machine settin…
Browse files Browse the repository at this point in the history
…g file correctly update changes of the google spreadsheet(to correctly retrieve changed header columns).
  • Loading branch information
kimsama committed Aug 9, 2016
1 parent d21265b commit 0f81487
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions GDataPlugin/Editor/GoogleMachineEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ protected override void Import(bool reimport = false)
else
headerDic = machine.HeaderColumnList.ToDictionary(k => k.name);

List<HeaderColumn> tmpColumnList = new List<HeaderColumn>();

// query the first columns only.
DoCellQuery((cell) =>
{

Expand All @@ -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();
}
Expand Down

0 comments on commit 0f81487

Please sign in to comment.