Fix Object.GetInstanceID() obsoletion in Unity 6000.4+ - #112
Merged
Conversation
alexanderlarsen
commented
Jul 26, 2026
Owner
- Add GetInstanceIDCompat() extension that calls Object.GetEntityID() on Unity 6000.4+ and falls back to Object.GetInstanceID() on older versions
- Update ContextIdentity and SceneHierarchyUtility to use the compat extension
- Extend CI test matrix with 6000.4.12f1, 6000.5.0f1, and 6000.5.5f1
- Update tested Unity versions doc (bump 6.4 max, add 6.5 range)
- Bump package version to 1.2.2 and add CHANGELOG entry
- Add GetInstanceIDCompat() extension that calls Object.GetEntityID() on Unity 6000.4+ and falls back to Object.GetInstanceID() on older versions - Update ContextIdentity and SceneHierarchyUtility to use the compat extension - Extend CI test matrix with 6000.4.12f1, 6000.5.0f1, and 6000.5.5f1 - Update tested Unity versions doc (bump 6.4 max, add 6.5 range) - Bump package version to 1.2.2 and add CHANGELOG entry
- Add SceneExtensions.GetHandleCompat() reading Scene handle via GetRawData() on 6000.4+ and falling back to Scene.handle on older versions - Widen ContextIdentity/ContextData keys from int to long so instance IDs and the raw scene handle are stored without truncation - Use GetInstanceIDCompat()/GetHandleCompat() in ContextIdentity and tests - Update ContextIdentityTests to use the compat extensions - Document changes under CHANGELOG 1.2.2
- Call GetRawData() on scene.handle (SceneHandle), not on Scene directly, fixing CS1061 on 6000.4+ - Cast scene.handle to int in the pre-6000.4 branch to resolve CS0457: on 6000.3 Scene.handle returns a SceneHandle with implicit int and uint operators, making the direct widening to long ambiguous
- Correct GetInstanceIDCompat() to read the raw entity id via EntityId.ToULong(GetEntityId()) on 6000.4+ (was GetEntityID()) - Add GetInstanceIDBoxedCompat() returning the id boxed as the exact type SetExpanded expects: EntityId on 6000.4+, int on older versions - Use the boxed helper at both SceneHierarchyUtility SetExpanded call sites, fixing an ArgumentException from passing a boxed long to a method that now takes EntityId
- Guard PropertyModel against a null SerializedProperty when Unity cannot serialize a field (e.g. a multidimensional array), which previously threw on the isArray access - Such fields are already filtered out before rendering, so they are simply omitted from the inspector, matching Unity's default behavior - Document the fix under CHANGELOG 1.2.2
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.