Skip to content

[BUG] Unity 6000.5 compilation fails because GetInstanceID is an obsolete error #1134

Description

@gdgeek

Describe the bug

The latest stable MRTK packages do not compile with Unity 6000.5 because Unity changed UnityEngine.Object.GetInstanceID() from an obsolete warning to an obsolete error.

Confirmed affected packages:

  • org.mixedrealitytoolkit.input 3.3.0
  • org.mixedrealitytoolkit.spatialmanipulation 3.4.0

The same calls are also present in Input 4.0.0-pre.2 and the current main branch.

This blocks Editor compilation before entering Play Mode or building the project.

To reproduce

  1. Open a project with Unity 6000.5.5f1.
  2. Install MRTK Input 3.3.0 and Spatial Manipulation 3.4.0.
  3. Allow Unity to compile the packages.
  4. Observe the CS0619 errors.

Actual behavior

Spatial Manipulation 3.4.0:

Editor/Constraints/ConstraintManagerEditor.cs(291,66): error CS0619: 'Object.GetInstanceID()' is obsolete: 'GetInstanceID is deprecated. Use GetEntityId instead. This will be removed in a future version.'
Editor/Constraints/ConstraintManagerEditor.cs(373,76): error CS0619: 'Object.GetInstanceID()' is obsolete: 'GetInstanceID is deprecated. Use GetEntityId instead. This will be removed in a future version.'

Input 3.3.0:

Editor/Inspectors/InteractionModeManagerEditor.cs(91,25): error CS0619: 'Object.GetInstanceID()' is obsolete: 'GetInstanceID is deprecated. Use GetEntityId instead. This will be removed in a future version.'

Affected patterns include:

constraintManager.GetInstanceID()
selectedConstraintManager.GetInstanceID()

HashSet<int> seenInstanceIDs = new HashSet<int>();
int instanceID = key.objectReferenceValue.GetInstanceID();

Expected behavior

MRTK should compile on Unity 6000.5 using EntityId while retaining compatibility with the packages' older supported Unity versions.

For example, the duplicate mapping logic can use HashSet<EntityId>, GetEntityId(), and EntityId.None on supported Unity versions. Conditional compilation or a compatibility helper may be needed because the packages currently support Unity versions where EntityId is unavailable.

Screenshots

Unity Console reports the CS0619 errors above during package compilation.

Your setup

  • Unity Version: 6000.5.5f1
  • MRTK Input: 3.3.0
  • MRTK Spatial Manipulation: 3.4.0
  • Editor OS: macOS
  • Regression check: Unity 6000.4.6f1 reports GetInstanceID() as an obsolete warning; Unity 6000.5.5f1 reports it as an obsolete error.

Target platform

Editor compilation issue; platform-independent. Observed in an iOS/OpenXR project.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions