#3615·mujoco

Unity 6.6 support

Author: sebas77Created Sep 23, 2026Updated Sep 28, 2026
Labelsenhancement

The feature, motivation and pitch

Unity 6.6 deprecated GetInstanceId and now Only GetEntityId is available. However this test assumes something that is not true anymore

  [Test]
  public void SiblingRootsAreOrderedByInstanceId() {
    _fakeBodyA.enabled = true;
    _fakeBodyB.enabled = true;
    var mjcf = _scene.CreateScene(skipCompile:true);

#if UNITY_6000_5_OR_NEWER
    var first = EntityId.ToULong(_fakeBodyA.GetEntityId()) < EntityId.ToULong(_fakeBodyB.GetEntityId())
        ? _fakeBodyA : _fakeBodyB;
    var second = EntityId.ToULong(_fakeBodyA.GetEntityId()) < EntityId.ToULong(_fakeBodyB.GetEntityId())
        ? _fakeBodyB : _fakeBodyA;
#else
    var first = _fakeBodyA.GetInstanceID() < _fakeBodyB.GetInstanceID() ? _fakeBodyA : _fakeBodyB;
    var second = _fakeBodyA.GetInstanceID() < _fakeBodyB.GetInstanceID() ? _fakeBodyB : _fakeBodyA;
#endif

    int firstIndex = int.Parse(first.MujocoName.Replace("component_", ""));
    int secondIndex = int.Parse(second.MujocoName.Replace("component_", ""));
    Assert.That(firstIndex, Is.LessThan(secondIndex));

    var bodyNodes = mjcf.SelectNodes("/mujoco/worldbody/body");
    var bodyNames = new List<string>();
    foreach (XmlNode node in bodyNodes) {
      bodyNames.Add(node.Attributes["name"].Value);
    }
    Assert.That(bodyNames.IndexOf(first.MujocoName), Is.LessThan(bodyNames.IndexOf(second.MujocoName)));
  }

the new test I wrote cannot work, because the test was relying on the apparent monotonicity of GetInstanceId which is not a contract for the new GetEntityId. I couldn't open a PR because of this.

Alternatives

No response

Additional context

No response