Allow models without numerical suffixes.
This is important for MJPC, where some element special names (e.g., a site called "trace0", or different custom numeric fields) are used. PiperOrigin-RevId: 502338391 Change-Id: I632b5d633c92b82b60160daeeb169693225640a3
This commit is contained in:
committed by
Copybara-Service
parent
d022cd1a31
commit
f3c966796f
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user