Skip to content

Unity 6.6 support #3615

Description

@sebas77

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions