diff --git a/Assets/uREPL/Scripts/Core/Extension.cs b/Assets/uREPL/Scripts/Core/Extension.cs new file mode 100644 index 0000000..ff594eb --- /dev/null +++ b/Assets/uREPL/Scripts/Core/Extension.cs @@ -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); + } +} + +} diff --git a/Assets/uREPL/Scripts/Core/Extension.cs.meta b/Assets/uREPL/Scripts/Core/Extension.cs.meta new file mode 100644 index 0000000..fcf664a --- /dev/null +++ b/Assets/uREPL/Scripts/Core/Extension.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f7b0f7f523c47c0459562362785f1ff6 +timeCreated: 1471165477 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: e595625465c294b69827ba1876777de0, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/uREPL/Scripts/Gui/FieldItems/SingleFieldItem.cs b/Assets/uREPL/Scripts/Gui/FieldItems/SingleFieldItem.cs index 2dade2c..c3c9455 100644 --- a/Assets/uREPL/Scripts/Gui/FieldItems/SingleFieldItem.cs +++ b/Assets/uREPL/Scripts/Gui/FieldItems/SingleFieldItem.cs @@ -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() diff --git a/Assets/uREPL/Scripts/Gui/FieldItems/Vector2FieldItem.cs b/Assets/uREPL/Scripts/Gui/FieldItems/Vector2FieldItem.cs index 69332a3..475cb4f 100644 --- a/Assets/uREPL/Scripts/Gui/FieldItems/Vector2FieldItem.cs +++ b/Assets/uREPL/Scripts/Gui/FieldItems/Vector2FieldItem.cs @@ -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(); } } diff --git a/Assets/uREPL/Scripts/Gui/FieldItems/Vector3FieldItem.cs b/Assets/uREPL/Scripts/Gui/FieldItems/Vector3FieldItem.cs index d9eb55c..926b472 100644 --- a/Assets/uREPL/Scripts/Gui/FieldItems/Vector3FieldItem.cs +++ b/Assets/uREPL/Scripts/Gui/FieldItems/Vector3FieldItem.cs @@ -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(); } } diff --git a/Assets/uREPL/Scripts/Gui/FieldItems/Vector4FieldItem.cs b/Assets/uREPL/Scripts/Gui/FieldItems/Vector4FieldItem.cs index 2bfcacf..e538fce 100644 --- a/Assets/uREPL/Scripts/Gui/FieldItems/Vector4FieldItem.cs +++ b/Assets/uREPL/Scripts/Gui/FieldItems/Vector4FieldItem.cs @@ -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(); } } diff --git a/Assets/uREPL/Scripts/Gui/OutputItems/GameObjectItem.cs b/Assets/uREPL/Scripts/Gui/OutputItems/GameObjectItem.cs index 1ee407a..4bd8134 100644 --- a/Assets/uREPL/Scripts/Gui/OutputItems/GameObjectItem.cs +++ b/Assets/uREPL/Scripts/Gui/OutputItems/GameObjectItem.cs @@ -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(); } } @@ -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(); } } @@ -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(); } } diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index 4fdc7ac..4a6754e 100644 Binary files a/ProjectSettings/ProjectSettings.asset and b/ProjectSettings/ProjectSettings.asset differ