From f8b1fce6e5c087787afcaf059555f902043ae7cc Mon Sep 17 00:00:00 2001 From: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com> Date: Mon, 24 Aug 2026 02:37:48 +0100 Subject: [PATCH] Serialize Unity hinge reference with invariant culture --- unity/Runtime/Components/Joints/MjHingeJoint.cs | 2 +- .../Editor/Components/Joints/MjHingeJointTests.cs | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/unity/Runtime/Components/Joints/MjHingeJoint.cs b/unity/Runtime/Components/Joints/MjHingeJoint.cs index 08e5958b1b0..cded0d4aa20 100644 --- a/unity/Runtime/Components/Joints/MjHingeJoint.cs +++ b/unity/Runtime/Components/Joints/MjHingeJoint.cs @@ -91,7 +91,7 @@ protected override XmlElement OnGenerateMjcf(XmlDocument doc) { throw new ArgumentException("Lower range value can't be bigger than Higher"); } mjcf.SetAttribute("range", MjEngineTool.MakeLocaleInvariant($"{RangeLower} {RangeUpper}")); - mjcf.SetAttribute("ref", $"{Configuration}"); + mjcf.SetAttribute("ref", MjEngineTool.MakeLocaleInvariant($"{Configuration}")); return mjcf; } diff --git a/unity/Tests/Editor/Components/Joints/MjHingeJointTests.cs b/unity/Tests/Editor/Components/Joints/MjHingeJointTests.cs index cff7529373a..9b785c27b6d 100644 --- a/unity/Tests/Editor/Components/Joints/MjHingeJointTests.cs +++ b/unity/Tests/Editor/Components/Joints/MjHingeJointTests.cs @@ -15,6 +15,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Globalization; using System.Xml; using NUnit.Framework; using UnityEngine; @@ -68,6 +69,19 @@ public void GenerateLimits() { Assert.That(_doc.OuterXml, Does.Contain(@"range=""-20 10""")); } + [Test] + public void GenerateReferenceUsesInvariantCulture() { + var previousCulture = CultureInfo.CurrentCulture; + CultureInfo.CurrentCulture = new CultureInfo("fr-FR"); + try { + _joint.Configuration = 1.5f; + var element = _joint.GenerateMjcf("name", _doc); + Assert.That(element.GetAttribute("ref"), Is.EqualTo("1.5")); + } finally { + CultureInfo.CurrentCulture = previousCulture; + } + } + [Test] public void ParsingPosition() { var jointElement = (XmlElement)_doc.AppendChild(_doc.CreateElement("joint"));