Migrate instance-ID APIs to EntityId (6000.3+), widen handles to long#55
Merged
Conversation
Unity 6000.5 renamed the int-based instance ID APIs to the 64-bit EntityId type and marked Object.GetInstanceID() and EditorUtility.InstanceIDToObject(int) obsolete-as-error (CS0619). Add version-gated wrappers (GetObjectInstanceId / ResolveObjectById) that use the new EntityId APIs on Unity 6000.5+ and fall back to the legacy APIs on older versions (package still targets Unity 2022.3+). Instance-ID handles remain int across the protocol; on 6000.5+ they round-trip through EntityId.ToULong()/FromULong(). Also route the CLI's generated eval --id preamble through the new ResolveObjectById helper so it compiles under Unity 6000.5.
Widen instance-id handles to long; adopt EntityId from 6000.3 Builds on the 6000.5 EntityId migration. Moves the #if gate to 6000.3, where the int-based instance-ID APIs are already deprecated (CS0618) and EntityId exists, so 6.3/6.4 stop emitting deprecation warnings. Uses a three-way path because EntityId is int-backed on 6000.3/.4 (implicit int conversions) and only 64-bit (ToULong/FromULong) on 6000.5+. Surfaces handles as long end-to-end so a 6000.5 64-bit EntityId is never truncated; narrower ids widen and narrow back exactly: - Protocol DTOs: InstanceId, OpenedFromInstanceId, BlockedBy - CLI: --id options (snapshot, ui click), ParseInstanceIds + eval preamble - Package: wrappers, GetLongArgument, targetId/context paths, StageInfo - Rebuilt bundled UnityCtl.Protocol.dll Verified on 6000.3.15f1: compiles clean (no Safe Mode), deprecation warnings gone, snapshot --id round-trips. dotnet build + 482 tests pass. @
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #54 (builds on @bradar93's commit, included here with original authorship). Closes #54.
Problem
Unity deprecates the int-based instance-ID APIs (
Object.GetInstanceID(),EditorUtility.InstanceIDToObject(int)) — a warning (CS0618) from 6000.3, obsolete-as-error (CS0619) from 6000.5. The package emitted these warnings on 6.3 and would fail to compile on 6.5.Fix
Adopt the
EntityIdAPIs behind a version gate, surfacing handles aslongend-to-end.Gate at 6000.3, not 6000.5 — the int APIs are already deprecated there and
EntityIdexists, so 6.3/6.4 stop warning. The API shape differs by version (verified by reflectingUnityEngine.EntityIdin a live 6000.3.15f1 editor), so three regimes:EntityIdis 64-bit — round-trip viaEntityId.ToULong/FromULong.EntityIdis int-backed — implicitEntityId ↔ int. (NoToULong/FromULonghere — those are 6.5-only; the original Fix Unity 6000.5 compatibility: migrate InstanceID APIs to EntityId #54 single-path approach would not compile on 6.3.)GetInstanceID()/InstanceIDToObject(int).Handles widened to
longso a 6000.5 64-bit EntityId is never truncated; narrower ids widen and narrow back exactly:InstanceId,OpenedFromInstanceId,BlockedBy--idoptions (snapshot, ui click),ParseInstanceIds+ eval preambleGetLongArgument,targetId/contextpaths, localStageInfoUnityCtl.Protocol.dllTesting
dotnet buildclean ·dotnet test482 passed / 0 skipped (+2 tests for ids beyond int range)snapshot --idround-trips at runtime (positive, negative, and >int32 ids all parse and resolve)