Skip to content

Fix Object.GetInstanceID() obsoletion in Unity 6000.4+ - #112

Merged
alexanderlarsen merged 5 commits into
mainfrom
dev
Jul 26, 2026
Merged

Fix Object.GetInstanceID() obsoletion in Unity 6000.4+#112
alexanderlarsen merged 5 commits into
mainfrom
dev

Conversation

@alexanderlarsen

Copy link
Copy Markdown
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
@alexanderlarsen
alexanderlarsen merged commit ca92073 into main Jul 26, 2026
26 checks passed
@alexanderlarsen
alexanderlarsen deleted the dev branch July 26, 2026 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant