Skip to content

Commit

Permalink
fix locale bug #21.
Browse files Browse the repository at this point in the history
  • Loading branch information
hecomi committed Sep 2, 2019
1 parent d4530fe commit a0c73a6
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 37 deletions.
28 changes: 28 additions & 0 deletions Assets/uREPL/Scripts/Core/Extension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Globalization;

namespace uREPL
{

public static class Extensions
{
private static CultureInfo cultureInfo = new CultureInfo("en-US");

public static string AsString(this float value)
{
return value.ToString(cultureInfo);
}

public static string AsString(this object value)
{
return
(value is float) ? ((float)value).AsString() :
value.ToString();
}

public static float AsFloat(this string value)
{
return float.Parse(value, cultureInfo);
}
}

}
12 changes: 12 additions & 0 deletions Assets/uREPL/Scripts/Core/Extension.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/uREPL/Scripts/Gui/FieldItems/SingleFieldItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class SingleFieldItem : FieldItem
public override object value
{
get { return Convert.ChangeType(valueInputField.text, fieldType); }
protected set { valueInputField.text = value.ToString(); }
protected set { valueInputField.text = value.AsString(); }
}

void Start()
Expand Down
8 changes: 4 additions & 4 deletions Assets/uREPL/Scripts/Gui/FieldItems/Vector2FieldItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ public override object value
{
return Activator.CreateInstance(
fieldType,
float.Parse(xInputField.text),
float.Parse(yInputField.text));
xInputField.text.AsFloat(),
yInputField.text.AsFloat());
}
protected set
{
xInputField.text = fieldType.GetField("x").GetValue(value).ToString();
yInputField.text = fieldType.GetField("y").GetValue(value).ToString();
xInputField.text = fieldType.GetField("x").GetValue(value).AsString();
yInputField.text = fieldType.GetField("y").GetValue(value).AsString();
}
}

Expand Down
12 changes: 6 additions & 6 deletions Assets/uREPL/Scripts/Gui/FieldItems/Vector3FieldItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ public override object value
{
return Activator.CreateInstance(
fieldType,
float.Parse(xInputField.text),
float.Parse(yInputField.text),
float.Parse(zInputField.text));
xInputField.text.AsFloat(),
yInputField.text.AsFloat(),
zInputField.text.AsFloat());
}
protected set
{
xInputField.text = fieldType.GetField("x").GetValue(value).ToString();
yInputField.text = fieldType.GetField("y").GetValue(value).ToString();
zInputField.text = fieldType.GetField("z").GetValue(value).ToString();
xInputField.text = fieldType.GetField("x").GetValue(value).AsString();
yInputField.text = fieldType.GetField("y").GetValue(value).AsString();
zInputField.text = fieldType.GetField("z").GetValue(value).AsString();
}
}

Expand Down
16 changes: 8 additions & 8 deletions Assets/uREPL/Scripts/Gui/FieldItems/Vector4FieldItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ public override object value
{
return Activator.CreateInstance(
fieldType,
float.Parse(xInputField.text),
float.Parse(yInputField.text),
float.Parse(zInputField.text),
float.Parse(wInputField.text));
xInputField.text.AsFloat(),
yInputField.text.AsFloat(),
zInputField.text.AsFloat(),
wInputField.text.AsFloat());
}
protected set
{
xInputField.text = fieldType.GetField("x").GetValue(value).ToString();
yInputField.text = fieldType.GetField("y").GetValue(value).ToString();
zInputField.text = fieldType.GetField("z").GetValue(value).ToString();
wInputField.text = fieldType.GetField("w").GetValue(value).ToString();
xInputField.text = fieldType.GetField("x").GetValue(value).AsString();
yInputField.text = fieldType.GetField("y").GetValue(value).AsString();
zInputField.text = fieldType.GetField("z").GetValue(value).AsString();
wInputField.text = fieldType.GetField("w").GetValue(value).AsString();
}
}

Expand Down
36 changes: 18 additions & 18 deletions Assets/uREPL/Scripts/Gui/OutputItems/GameObjectItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ public Vector3 position
get
{
return new Vector3(
float.Parse(posX.text),
float.Parse(posY.text),
float.Parse(posZ.text));
posX.text.AsFloat(),
posY.text.AsFloat(),
posZ.text.AsFloat());
}
protected set
{
posX.text = value.x.ToString();
posY.text = value.y.ToString();
posZ.text = value.z.ToString();
posX.text = value.x.AsString();
posY.text = value.y.AsString();
posZ.text = value.z.AsString();
}
}

Expand All @@ -46,16 +46,16 @@ public Quaternion rotation
get
{
return Quaternion.Euler(
float.Parse(rotX.text),
float.Parse(rotY.text),
float.Parse(rotZ.text));
rotX.text.AsFloat(),
rotY.text.AsFloat(),
rotZ.text.AsFloat());
}
protected set
{
var euler = value.eulerAngles;
rotX.text = euler.x.ToString();
rotY.text = euler.y.ToString();
rotZ.text = euler.z.ToString();
rotX.text = euler.x.AsString();
rotY.text = euler.y.AsString();
rotZ.text = euler.z.AsString();
}
}

Expand All @@ -64,15 +64,15 @@ public Vector3 scale
get
{
return new Vector3(
float.Parse(scaleX.text),
float.Parse(scaleY.text),
float.Parse(scaleZ.text));
scaleX.text.AsFloat(),
scaleY.text.AsFloat(),
scaleZ.text.AsFloat());
}
protected set
{
scaleX.text = value.x.ToString();
scaleY.text = value.y.ToString();
scaleZ.text = value.z.ToString();
scaleX.text = value.x.AsString();
scaleY.text = value.y.AsString();
scaleZ.text = value.z.AsString();
}
}

Expand Down
Binary file modified ProjectSettings/ProjectSettings.asset
Binary file not shown.

0 comments on commit a0c73a6

Please sign in to comment.