Created
August 9, 2024 10:49
-
-
Save robinkanatzar/99b484fe7e6b6a92915c8f9925b616b4 to your computer and use it in GitHub Desktop.
Accessibility + visionOS: RealityKit Accessibility Annotations
This file contains 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
import RealityKit | |
// 1 - Create RealityKit Entity | |
let modelEntity = ModelEntity(/* ... */) | |
// 2 - Create AccessibilityComponent | |
var accessibilityComponent = AccessibilityComponent() | |
// 3 - Expose to assistive technology | |
accessibilityComponent.isAccessibilityElement = true | |
// 4 - Add basic annotations (label, value, traits) | |
accessibilityComponent.label = "Label" | |
accessibilityComponent.value = "Value" | |
accessibilityComponent.traits = [.button] | |
// 5 - Add custom actions and rotors | |
accessibilityComponent.customActions = [/* ... */] | |
accessibilityComponent.customRotors = [/* ... */] | |
// 6 - Assign AccessibilityComponent to RealityKit Entity | |
modelEntity.components?[AccessibilityComponent.self] = accessibilityComponent | |
// 7 - Update the AccessibilityComponent as the app state changes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment