diff --git a/unity/Runtime/Components/MjGlobalSettings.cs b/unity/Runtime/Components/MjGlobalSettings.cs index 618555e9..ad8b7e0f 100644 --- a/unity/Runtime/Components/MjGlobalSettings.cs +++ b/unity/Runtime/Components/MjGlobalSettings.cs @@ -327,6 +327,9 @@ public class MjGlobalSettings : MonoBehaviour { [Tooltip("Scales the force applied by the mouse spring.")] public float MouseSpringStiffness = 100; + [Tooltip("If false, numerical suffixes will be aded to ensure name uniqueness.")] + public bool UseRawGameObjectNames; + public MjOptionStruct GlobalOptions = MjOptionStruct.Default; public MjSizeStruct GlobalSizes = MjSizeStruct.Default; diff --git a/unity/Runtime/Tools/MjcfGenerationContext.cs b/unity/Runtime/Tools/MjcfGenerationContext.cs index 6269bc84..c2ff59d8 100644 --- a/unity/Runtime/Tools/MjcfGenerationContext.cs +++ b/unity/Runtime/Tools/MjcfGenerationContext.cs @@ -51,15 +51,15 @@ public class MjcfGenerationContext { return _meshAssets[mesh]; } - // Generates a Unique name for the specified component. - // Uniqueness of names is required for every type independently. - // The per-type uniqueness will be guaranteed by the combination of information used: - // - name of the host GameObject. - // - number of names that have been generated to date. public string GenerateName(Component comp) { - var name = $"{comp.gameObject.name}_{_numGeneratedNames}"; - _numGeneratedNames++; - return name; + var settings = MjGlobalSettings.Instance; + if (settings?.UseRawGameObjectNames ?? false) { + return comp.gameObject.name; + } else { + var name = $"{comp.gameObject.name}_{_numGeneratedNames}"; + _numGeneratedNames++; + return name; + } } private void GenerateConfigurationMjcf(XmlElement mjcf) {