Skip to content

Commit

Permalink
removed redundant template path in GoogleMachine and ExcelMachine and…
Browse files Browse the repository at this point in the history
… directly assign the path from GoogleDataSettings's and ExcelSettings's
  • Loading branch information
kimsama committed Dec 24, 2017
1 parent 35c1f9d commit fadbe3a
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 36 deletions.
8 changes: 3 additions & 5 deletions Assets/QuickSheet/ExcelPlugin/Editor/ExcelMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,13 @@ public int CurrentSheetIndex
[SerializeField]
protected int currentSelectedSheet = 0;

// excel and google plugin have its own template files,
// so we need to set the different path when the asset file is created.
private readonly string excelTemplatePath = "QuickSheet/ExcelPlugin/Templates";

/// <summary>
/// Note: Called when the asset file is created.
/// </summary>
private void Awake() {
TemplatePath = excelTemplatePath;
// excel and google plugin have its own template files,
// so we need to set the different path when the asset file is created.
TemplatePath = ExcelSettings.Instance.TemplatePath;
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Assets/QuickSheet/ExcelPlugin/Editor/ExcelSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace UnityQuickSheet
public class ExcelSettings : SingletonScriptableObject<ExcelSettings>
{
/// <summary>
/// A path where template .txt files are.
/// A default path where .txt template files are.
/// </summary>
public string TemplatePath = "QuickSheet/ExcelPlugin/Templates";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ public ListEntry Serialize(T e) {

public ListEntry Serialize(T e, ListEntry record) {
foreach (var p in typeof (T).GetProperties()) {
if (p.CanRead) {
record.Elements.Add(new ListEntry.Custom {
LocalName = p.Name.ToLowerInvariant(), // for some reason this HAS to be lowercase or it throws
Value = ToNullOrString(p.GetValue(e, null)),
});
}
if (p.CanRead) {
record.Elements.Add(new ListEntry.Custom {
LocalName = p.Name.ToLowerInvariant(), // for some reason this HAS to be lowercase or it throws
Value = ToNullOrString(p.GetValue(e, null)),
});
}
}
return record;
}
Expand All @@ -41,14 +41,14 @@ public object ConvertFrom(object value, Type t) {
var nc = new NullableConverter(t);
return nc.ConvertFrom(value);
}
//HACK: modified to return enum.
if (t.IsEnum)
{
return Enum.Parse(t, value.ToString(), true);
}
else
return Convert.ChangeType(value, t);
//HACK: modified to return enum.
if (t.IsEnum)
{
return Enum.Parse(t, value.ToString(), true);
}
else
return Convert.ChangeType(value, t);
}

public T Deserialize(ListEntry e) {
Expand All @@ -58,10 +58,10 @@ public T Deserialize(ListEntry e) {
var property = t.GetProperty(c.LocalName, BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Public);
if (property == null)
continue;
if (property.CanWrite) {
try
{
if (property.CanWrite) {
try
{
if (property.PropertyType.IsArray)
{
const char DELIMETER = ','; // '\n'
Expand Down Expand Up @@ -123,12 +123,12 @@ public T Deserialize(ListEntry e) {

property.SetValue(r, value, null);
}
}
catch(Exception exc)
{
Debug.LogError ("GDataDB Serialization Exception: " + exc.Message + " ListEntry LocalName: " + c.LocalName);
}
}
}
catch(Exception exc)
{
Debug.LogError ("GDataDB Serialization Exception: " + exc.Message + " ListEntry LocalName: " + c.LocalName);
}
}
}
return r;
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/QuickSheet/GDataPlugin/Editor/GoogleDataSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public string JsonFilePath
private string jsonFilePath = string.Empty;

/// <summary>
/// A path where template .txt files are.
/// A default path where .txt template files are.
/// </summary>
public string TemplatePath = "QuickSheet/GDataPlugin/Templates";

Expand Down
8 changes: 3 additions & 5 deletions Assets/QuickSheet/GDataPlugin/Editor/GoogleMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,15 @@ internal class GoogleMachine : BaseMachine
[SerializeField]
public static string assetFileName = "GoogleMachine.asset";

// excel and google plugin have its own template files,
// so we need to set the different path when the asset file is created.
private readonly string gDataTemplatePath = "QuickSheet/GDataPlugin/Templates";

public string AccessCode = "";

/// <summary>
/// Note: Called when the asset file is created.
/// </summary>
private void Awake() {
TemplatePath = gDataTemplatePath;
// excel and google plugin have its own template files,
// so we need to set the different path when the asset file is created.
TemplatePath = GoogleDataSettings.Instance.TemplatePath;
}

/// <summary>
Expand Down

0 comments on commit fadbe3a

Please sign in to comment.