Skip to content

Unity 6.5 compile error: Object.GetInstanceID() is obsolete and should be migrated to GetEntityId() #231

Description

@onsemy

Summary

com.akiojin.unity-cli-bridge fails to compile in Unity 6.5 because several editor-side bridge scripts still call UnityEngine.Object.GetInstanceID().

In Unity 6.5, Object.GetInstanceID() is now obsolete and Unity reports it as a CS0619 compile error:

Object.GetInstanceID() is obsolete: GetInstanceID is deprecated. Use GetEntityId instead. This will be removed in a future version.

Because the bridge package uses GetInstanceID() in multiple handlers and helper classes, the Unity project cannot finish compiling after the package is imported.

Environment

  • Unity version: Unity 6.5 / 6000.5.x
  • Package: com.akiojin.unity-cli-bridge
  • Package source/hash shown in PackageCache: 3a41bf6dc060
  • Install method: Unity Package Manager / Git package
  • OS: macOS
  • Project type: Unity 6.5 project using akiojin/unity-cli

Steps to reproduce

  1. Open a Unity 6.5 project.
  2. Add com.akiojin.unity-cli-bridge from this repository.
  3. Let Unity import and compile the package.
  4. Check the Unity Console.

Actual result

Unity compilation fails with CS0619 errors from unity-cli-bridge:

Library/PackageCache/com.akiojin.unity-cli-bridge@3a41bf6dc060/Editor/Helpers/RuntimeChangeJournal.cs(39,22): error CS0619: 'Object.GetInstanceID()' is obsolete: 'GetInstanceID is deprecated. Use GetEntityId instead. This will be removed in a future version.'

Library/PackageCache/com.akiojin.unity-cli-bridge@3a41bf6dc060/Editor/Handlers/GameObjectHandler.cs(105,26): error CS0619: 'Object.GetInstanceID()' is obsolete: 'GetInstanceID is deprecated. Use GetEntityId instead. This will be removed in a future version.'

Library/PackageCache/com.akiojin.unity-cli-bridge@3a41bf6dc060/Editor/Handlers/GameObjectHandler.cs(381,26): error CS0619: 'Object.GetInstanceID()' is obsolete: 'GetInstanceID is deprecated. Use GetEntityId instead. This will be removed in a future version.'

Library/PackageCache/com.akiojin.unity-cli-bridge@3a41bf6dc060/Editor/Handlers/GameObjectHandler.cs(468,26): error CS0619: 'Object.GetInstanceID()' is obsolete: 'GetInstanceID is deprecated. Use GetEntityId instead. This will be removed in a future version.'

Library/PackageCache/com.akiojin.unity-cli-bridge@3a41bf6dc060/Editor/Handlers/ComponentHandler.cs(2030,30): error CS0619: 'Object.GetInstanceID()' is obsolete: 'GetInstanceID is deprecated. Use GetEntityId instead. This will be removed in a future version.'

Library/PackageCache/com.akiojin.unity-cli-bridge@3a41bf6dc060/Editor/Handlers/SceneAnalysisHandler.cs(393,38): error CS0619: 'Object.GetInstanceID()' is obsolete: 'GetInstanceID is deprecated. Use GetEntityId instead. This will be removed in a future version.'

Library/PackageCache/com.akiojin.unity-cli-bridge@3a41bf6dc060/Editor/Handlers/SelectionHandler.cs(272,33): error CS0619: 'Object.GetInstanceID()' is obsolete: 'GetInstanceID is deprecated. Use GetEntityId instead. This will be removed in a future version.'

Expected result

The bridge package should compile successfully in Unity 6.5.

Suspected cause

Unity 6.5 deprecates UnityEngine.Object.GetInstanceID() and requires UnityEngine.Object.GetEntityId() instead.

The affected bridge code appears to expose or store Unity object identifiers as int values returned by GetInstanceID(), for example in:

  • RuntimeChangeJournal.cs
  • GameObjectHandler.cs
  • ComponentHandler.cs
  • SceneAnalysisHandler.cs
  • SelectionHandler.cs

Suggested fix

Please consider migrating the bridge from Object.GetInstanceID() to Object.GetEntityId() for Unity 6.5 compatibility.

A simple GetEntityId().GetHashCode() replacement may not be ideal if the value is used as a stable or unique object identifier, because EntityId is no longer guaranteed to be representable as a single int going forward. It may be safer to:

  • use EntityId directly internally where possible,
  • update response DTOs/protocol fields that currently assume int id,
  • use EntityId.None / validity checks instead of 0-based instance ID assumptions,
  • add conditional compilation if older Unity versions still need to be supported.

For example, the bridge may need a compatibility layer around object identifiers instead of directly returning GetInstanceID() from each handler.

References

Thank you for maintaining unity-cli. This tool is very useful for Unity editor automation workflows, and Unity 6.5 compatibility would be greatly appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions