Skip to content

Fix for apple/unityplugins#102 - obsolete method in Unity 6000.4 and newer versions throws error. - #104

Draft
michalDerer wants to merge 8 commits into
apple:mainfrom
michalDerer:fix_obsolete_unity_methods
Draft

Fix for apple/unityplugins#102 - obsolete method in Unity 6000.4 and newer versions throws error.#104
michalDerer wants to merge 8 commits into
apple:mainfrom
michalDerer:fix_obsolete_unity_methods

Conversation

@michalDerer

Copy link
Copy Markdown

A script in the Apple.Core plugin contains a method that becomes obsolete in Unity 6000.4 and newer versions, causing an error.
In that case, GetEntityId() must be used instead.

Fixes #102

@ryzngard

ryzngard commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

There seem to be a few other places this is used https://github.com/search?q=repo%3Aapple%2Funityplugins%20GetInstanceID&type=code

Can you update those as well?

@michalDerer

Copy link
Copy Markdown
Author

Yes, I'll check it out.

@michalDerer
michalDerer marked this pull request as draft August 12, 2026 00:16
@michalDerer
michalDerer marked this pull request as ready for review August 18, 2026 14:18
@michalDerer

Copy link
Copy Markdown
Author

Done.

The old, obsolete method GetInstanceID() returns an int, while the new replacement method GetEntityId() returns an structs EntityId, from which a ulong representing the entityId can be obtained.

In Apple.Accessibility, unity and native part are storing elements using int keys obtained by GetInstanceID().
For unity 6000.4 or newer, ulong keys are used in unity and native code.
To support this, additional bridging methods for ulong keys were added to the native code.

The remaining changes are minor replacements.

@ryzngard ryzngard left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing this! I think we can find a simplified path forward in Accessibility to make maintenance easier.

static AccessibilityTraitsDelegate __axTraitsDelegate = NULL;
static AccessibilityTraitsDelegate2 __axTraitsDelegate2 = NULL;
APPLE_ACCESSIBILITY_EXTERN void _UnityAX_registerAccessibilityTraits(AccessibilityTraitsDelegate delegate) { __axTraitsDelegate = delegate; }
APPLE_ACCESSIBILITY_EXTERN void _UnityAX_registerAccessibilityTraits2(AccessibilityTraitsDelegate2 delegate) { __axTraitsDelegate2 = delegate; }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likely a better approach here is to just convert everything to uint64_t and get rid of the int32_t. To my understanding that shouldn't change behavior and uint64_t is guaranteed to be able to hold all values int32_t can

@michalDerer michalDerer Aug 20, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, on native and unity side could remain only uint64_t interface.
Then in unity, code for unity versions 6000.3 or older would had to be converted to use uint64_t keys and interface.
I do the changes.

@michalDerer
michalDerer marked this pull request as draft August 21, 2026 15:41
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.

unity 6.5 throws errors

2 participants