Merge pull request #515 from stonfute:main

PiperOrigin-RevId: 479296643
Change-Id: Id510d76892d59c8d819c4115610fb7ea8a0efe27
This commit is contained in:
Copybara-Service
2022-10-06 06:16:11 -07:00
+3 -2
View File
@@ -15,6 +15,7 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Xml; using System.Xml;
using System.Globalization;
using UnityEngine; using UnityEngine;
namespace Mujoco { namespace Mujoco {
@@ -43,7 +44,7 @@ public static class XmlElementExtensions {
} }
var strValue = element.GetAttribute(name); var strValue = element.GetAttribute(name);
float parsedValue; float parsedValue;
if (float.TryParse(strValue, out parsedValue)) { if (float.TryParse(strValue, NumberStyles.Any, CultureInfo.InvariantCulture, out parsedValue)) {
return parsedValue; return parsedValue;
} else { } else {
throw new ArgumentException($"'{strValue}' is not a float."); throw new ArgumentException($"'{strValue}' is not a float.");
@@ -151,7 +152,7 @@ public static class XmlElementExtensions {
var result = new float[resultLength]; var result = new float[resultLength];
for (var i = 0; i < components.Length; ++i) { for (var i = 0; i < components.Length; ++i) {
float componentValue; float componentValue;
if (float.TryParse(components[i], out componentValue)) { if (float.TryParse(components[i], NumberStyles.Any, CultureInfo.InvariantCulture, out componentValue)) {
result[i] = componentValue; result[i] = componentValue;
} else { } else {
throw new ArgumentException($"'{components[i]}' is not a float."); throw new ArgumentException($"'{components[i]}' is not a float.");