# AccessibilityHierarchy

> The hierarchy data model that the screen reader uses to navigate and interact with a Unity application.

## Definition

* **Type:** Class
* **Namespace:** [UnityEngine.Accessibility](/engine/6000.5/script-reference/unityengine/accessibility.md)
* **Assembly:** UnityEngine.AccessibilityModule

```csharp
public class AccessibilityHierarchy
```

## Remarks

For a screen reader to navigate an application, it must receive information like what the accessible elements are, where they are placed on the screen, what role they have, and how the user can interact with them. This information needs to be organized in a hierarchy of data structures called the `AccessibilityHierarchy`.

The accessibility hierarchy operates independently of the UI hierarchy. You can use these APIs with any UI system and even with non-UI elements, such as elements that are part of your game.

The data structures that form the accessibility hierarchy are called [AccessibilityNode](/engine/6000.5/script-reference/unityengine/accessibility/accessibilitynode.md)s. Each node represents a visual element that needs to be accessible to the screen reader. A node can have zero or more [\_children](/engine/6000.5/script-reference/unityengine/accessibility/accessibilitynode/children.md) and one [\_parent](/engine/6000.5/script-reference/unityengine/accessibility/accessibilitynode/parent.md). [\_rootNodes](/engine/6000.5/script-reference/unityengine/accessibility/accessibilityhierarchy/rootnodes.md) are the top-level nodes in the hierarchy, having no parent.

Users can navigate the accessibility hierarchy sequentially by moving the screen reader focus from one node to another. Some screen readers follow a depth-first traversal order, navigating to a node's children before moving to its siblings, while others navigate based on the position of the nodes on the screen (given by their [\_frame](/engine/6000.5/script-reference/unityengine/accessibility/accessibilitynode/frame.md)).

To enable the screen reader to navigate an accessibility hierarchy, you must assign the hierarchy to [\_activeHierarchy](/engine/6000.5/script-reference/unityengine/accessibility/assistivesupport/activehierarchy.md) to activate it. To manage system resources efficiently, Unity does not save the active hierarchy while the screen reader is off. You must activate the hierarchy each time the screen reader is turned on (see [\_screenReaderStatusChanged](/engine/6000.5/script-reference/unityengine/accessibility/assistivesupport/screenreaderstatuschanged.md) and [\_isScreenReaderEnabled](/engine/6000.5/script-reference/unityengine/accessibility/assistivesupport/isscreenreaderenabled.md)).

If you modify the active hierarchy, then you must notify the screen reader by calling [IAccessibilityNotificationDispatcher.SendLayoutChanged](/engine/6000.5/script-reference/unityengine/accessibility/iaccessibilitynotificationdispatcher/sendlayoutchanged.md) or [IAccessibilityNotificationDispatcher.SendScreenChanged](/engine/6000.5/script-reference/unityengine/accessibility/iaccessibilitynotificationdispatcher/sendscreenchanged.md) (depending on the scale of the changes). Modifications in the accessibility hierarchy consist of calls to:

* [AccessibilityHierarchy.AddNode](/engine/6000.5/script-reference/unityengine/accessibility/accessibilityhierarchy/addnode.md)

* [AccessibilityHierarchy.Clear](/engine/6000.5/script-reference/unityengine/accessibility/accessibilityhierarchy/clear.md)

* [AccessibilityHierarchy.InsertNode](/engine/6000.5/script-reference/unityengine/accessibility/accessibilityhierarchy/insertnode.md)

* [AccessibilityHierarchy.MoveNode](/engine/6000.5/script-reference/unityengine/accessibility/accessibilityhierarchy/movenode.md)

* [AccessibilityHierarchy.RemoveNode](/engine/6000.5/script-reference/unityengine/accessibility/accessibilityhierarchy/removenode.md)

* Modifications to node [\_frame](/engine/6000.5/script-reference/unityengine/accessibility/accessibilitynode/frame.md) values.

These APIs are currently supported on the following platforms:

* [RuntimePlatform.Android](/engine/6000.5/script-reference/unityengine/runtimeplatform/android.md) - starting with Android 8.0 (API level 26)

* [RuntimePlatform.IPhonePlayer](/engine/6000.5/script-reference/unityengine/runtimeplatform/iphoneplayer.md)

* [RuntimePlatform.OSXPlayer](/engine/6000.5/script-reference/unityengine/runtimeplatform/osxplayer.md)

* [RuntimePlatform.WindowsPlayer](/engine/6000.5/script-reference/unityengine/runtimeplatform/windowsplayer.md)

**Note**: Only the accessibility hierarchy for the application's main window is supported. Content displayed on additional windows, such as on secondary displays, is not exposed to screen readers.

Additional Resources:

* [Accessibility for mobile applications](/engine/6000.5/manual/accessibility.md)

* [Sample project using the accessibility APIs](https://github.com/Unity-Technologies/a11y-public-sample)

## Constructors

| Constructor                                                                                                          | Description                                                                                                                                     |
| -------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| [AccessibilityHierarchy()](/engine/6000.5/script-reference/unityengine/accessibility/accessibilityhierarchy/ctor.md) | Initializes and returns an empty [AccessibilityHierarchy](/engine/6000.5/script-reference/unityengine/accessibility/accessibilityhierarchy.md). |

## Properties

| Property                                                                                                   | Description                      |
| ---------------------------------------------------------------------------------------------------------- | -------------------------------- |
| [rootNodes](/engine/6000.5/script-reference/unityengine/accessibility/accessibilityhierarchy/rootnodes.md) | The root nodes of the hierarchy. |

## Methods

| Method                                                                                                                                 | Description                                                                                                                                                                                                        |
| -------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [AddNode](/engine/6000.5/script-reference/unityengine/accessibility/accessibilityhierarchy/addnode.md)                                 | Creates a new [AccessibilityNode](/engine/6000.5/script-reference/unityengine/accessibility/accessibilitynode.md) with the given label and adds it to the hierarchy under the given parent.                        |
| [Clear](/engine/6000.5/script-reference/unityengine/accessibility/accessibilityhierarchy/clear.md)                                     | Resets the hierarchy to an empty state, removing all nodes and the screen reader focus.                                                                                                                            |
| [ContainsNode](/engine/6000.5/script-reference/unityengine/accessibility/accessibilityhierarchy/containsnode.md)                       | Verifies whether the given node exists in the accessibility hierarchy.                                                                                                                                             |
| [GetLowestCommonAncestor](/engine/6000.5/script-reference/unityengine/accessibility/accessibilityhierarchy/getlowestcommonancestor.md) | Retrieves the lowest common ancestor of two nodes in the accessibility hierarchy.                                                                                                                                  |
| [InsertNode](/engine/6000.5/script-reference/unityengine/accessibility/accessibilityhierarchy/insertnode.md)                           | Creates a new [AccessibilityNode](/engine/6000.5/script-reference/unityengine/accessibility/accessibilitynode.md) with the given label and inserts it at the given index in the hierarchy, under the given parent. |
| [MoveNode](/engine/6000.5/script-reference/unityengine/accessibility/accessibilityhierarchy/movenode.md)                               | Moves the node elsewhere in the accessibility hierarchy. For example, under a different parent or at a different position in the parent's child list.                                                              |
| [RefreshNodeFrames](/engine/6000.5/script-reference/unityengine/accessibility/accessibilityhierarchy/refreshnodeframes.md)             | Refreshes the [\_frame](/engine/6000.5/script-reference/unityengine/accessibility/accessibilitynode/frame.md) of all nodes in the accessibility hierarchy.                                                         |
| [RemoveNode](/engine/6000.5/script-reference/unityengine/accessibility/accessibilityhierarchy/removenode.md)                           | Removes the node from the accessibility hierarchy and removes or re-parents its descendants.                                                                                                                       |
| [TryGetNode](/engine/6000.5/script-reference/unityengine/accessibility/accessibilityhierarchy/trygetnode.md)                           | Tries to retrieve the [AccessibilityNode](/engine/6000.5/script-reference/unityengine/accessibility/accessibilitynode.md) with the given ID in the hierarchy.                                                      |
| [TryGetNodeAt](/engine/6000.5/script-reference/unityengine/accessibility/accessibilityhierarchy/trygetnodeat.md)                       | Tries to retrieve the [AccessibilityNode](/engine/6000.5/script-reference/unityengine/accessibility/accessibilitynode.md) at the given screen coordinates.                                                         |
