UI Accessibility Plugin  Version 1.0.2
Make your UI accessible for visually impaired users
UAP_AccessibilityManager Class Reference

This is the main object to handle all the accessibility in an app. Please use the premade Accessibility Manager prefab. More...

Inheritance diagram for UAP_AccessibilityManager:

Public Types

enum  ESDirection { EUp = 0, EDown, ELeft, ERight }
 

Public Member Functions

delegate void OnPauseToggleCallbackFunc ()
 
delegate void OnTapEvent ()
 
delegate void OnSwipeEvent ()
 
delegate void OnAccessibilityModeChanged (bool enabled)
 
void OnSwipe (ESDirection dir, int fingerCount)
 

Static Public Member Functions

static void PauseAccessibility (bool pause)
 Temporarily suspend the core accessibility features. This is useful if your game requires direct touch input for gameplay. You can call this function regardless of whether the accessibility mode is enabled or not (if it is not, it will NOT enable it). There is no need to query the state of the plugin with IsEnabled() first. When accessibility is suspended but not disabled, the plugin will continue to listen to magic gestures (unless that is disabled in the Settings). Please see the documentation for a more thorough explanation. To turn off the accessibility completely, use EnableAccessibility() instead. More...
 
static void BlockInput (bool block, bool stopSpeakingOnBlock=true)
 This function temporarily blocks input from users to the Accessibility System. Use this to have the accessibility plugin ignore any input from users, but keep the touch blocker active that prevents blind users from accidentally hitting any of your UI elements.

This function is useful if you have a native dialog open, if you want to wait for a sound or animation to finish, or need an announcement to be done before you accept user input again.

If the Accessibility Plugin is inactive or paused, or is not set to handle UI this will have no effect.
This will not stop speech from playing, so you can still use the TTS functionality. Use this instead of ::PauseAccessibility if you still need speech. More...
 
static void ElementRemoved (AccessibleUIGroupRoot.Accessible_UIElement element)
 
static void ActivateContainer (AccessibleUIGroupRoot container, bool activate)
 Called by a UI container to make its content (un-)available for interaction. You don't need to call this function from your own code unless you write a custom implementation of AccessibleUIGroupRoot class. More...
 
static bool IsEnabled ()
 Returns whether Accessibility mode is enabled or not. This does not consider paused state. If the Accessibility mode is active, but currently paused, this function will still return true. If you need to know whether the mode is active, query IsActive() instead. More...
 
static bool IsActive ()
 Returns whether Accessibility mode is enabled and unpaused. If the plugin is enabled, but currently paused, this function will return true. Please use IsEnabled() if you want to query whether the plugin is enabled at all. More...
 
static bool IsCurrentPlatformSupported ()
 Convenience function to check whether the current platform is officially supported. Has no further effect on the plugin. More...
 
static void EnableMagicGestures (bool enable)
 
static void EnableAccessibility (bool enable, bool readNotification=false)
 Use this to completely enable/disable the accessibility plugin. If accessibility is disabled, there will be no reaction to any user input, calls to Say() will be ignored, and calls to PauseAccessibility() will have no effect.
Use this to turn on/off accessibility via your app's menu.
You can also use the Plugin Toggle component to do this automatically. See Plugin Toggle Documentation. More...
 
static void ToggleAccessibility ()
 
static bool GetSpeakDisabledInteractables ()
 
static void Say (string textToSay, bool canBeInterrupted=true, bool allowVoiceOver=true, UAP_AudioQueue.EInterrupt interrupts=UAP_AudioQueue.EInterrupt.Elements)
 Say something using platform independent Text To Speech. If you disabled TTS in the settings, or TTS is not available on the current platform, the call will be ignored. More...
 
static bool IsSpeaking ()
 This function returns whether there is currently voice audio playing. This includes Text-To-Speech voice or pre-recorded audio clips, if those were provided. It does not include sound effects.

Apps can use this if they want to wait for everything to be finished before triggering more audio. Works especially well in combination with temporary preventing input via BlockInput during the wait, to make sure not further voice output is started.

Please note that the function is not 100% exact. Depending on the TTS system, it isn't always possible to find out whether the voice is still speaking. So instead the system estimates an approximate speaking duration. More...
 
static bool IsTalkBackEnabledAndTouchExploreActive ()
 
static bool IsTalkBackEnabled ()
 Is Google TalkBack activated (on or suspended). It is impossible to tell whether TalkBack is currently suspended, as the system still reports it as active in that case. More...
 
static void RegisterOnPauseToggledCallback (OnPauseToggleCallbackFunc func)
 Register to be notified when the user made the Pause gesture / Magic Tap. See the documentation on Magic Gestures. More...
 
static void UnregisterOnPauseToggledCallback (OnPauseToggleCallbackFunc func)
 Unregister from notifications when the user made the Pause gesture / Magic Tap. See the documentation on Magic Gestures. More...
 
static void RegisterOnTwoFingerSingleTapCallback (OnTapEvent func)
 Register to be notified when the user tapped the screen once with two fingers. Using this callback ensures that the user did not intend to do a magic tap (two finger double tap). It is fired only after the double tap threshold time is up. More...
 
static void UnregisterOnTwoFingerSingleTapCallback (OnTapEvent func)
 Unregister from callback for two finger single taps. More...
 
static void RegisterOnThreeFingerSingleTapCallback (OnTapEvent func)
 Register to be notified when the user tapped the screen once with three fingers. Using this callback ensures that the user did not intend to do a three finger double or triple tap. It is fired only after the double tap threshold time is up. More...
 
static void UnregisterOnThreeFingerSingleTapCallback (OnTapEvent func)
 Unregister from callback for three finger single taps. More...
 
static void RegisterOnThreeFingerDoubleTapCallback (OnTapEvent func)
 Register to be notified when the user tapped the screen twice with three fingers. Using this callback ensures that the user did not intend to do a three finger triple tap. It is fired only after the double tap threshold time is up. More...
 
static void UnregisterOnThreeFingerDoubleTapCallback (OnTapEvent func)
 Unregister from callback for three finger double taps. More...
 
static void RegisterAccessibilityModeChangeCallback (OnAccessibilityModeChanged func)
 Get notified when the accessibility mode turns on/off. The Accessibility Plugin can be enabled by the user with a three finger triple tap at any time. In addition, if the app is resumed from suspension, and a screen reader is now detected and the plugin wasn't enabled yet, it will then enable itself as well. This serves as a safeguard for blind people that accidentally disable accessibility mode and exit and re-enter the app in hopes to restore accessibility mode.

More...
 
static void UnregisterAccessibilityModeChangeCallback (OnAccessibilityModeChanged func)
 Stop receiving notifications when the accessibility mode state changes. More...
 
static void SetTwoFingerSwipeUpHandler (OnTapEvent func)
 Overrides the regular two finger swipe up function, which is Read-From-Top. Use this to handle the gesture yourself. This will stop the Read-From-Top feature from working until ::ResetTwoFingerSwipeUpHandler is called.

This can be very useful during gameplay, if the gesture is used to read out stats or help instead. More...
 
static void ResetTwoFingerSwipeUpHandler ()
 
static void SetTwoFingerSwipeDownHandler (OnTapEvent func)
 Overrides the regular two finger swipe down function, which is Read-From-Current-Element. Use this to handle the gesture yourself. This will stop the Read-From-Current-Element feature from working until ::ResetTwoFingerSwipeDownHandler is called.

This can be very useful during gameplay, if the gesture is used to read out stats or help instead. More...
 
static void ResetTwoFingerSwipeDownHandler ()
 
static void SelectElement (GameObject element, bool forceRepeatItem=false)
 
static void MakeActiveContainer (AccessibleUIGroupRoot container, bool forceRepeatActiveItem=false)
 
static GameObject GetCurrentFocusObject ()
 Retrieve the GameObject containing the UI element that currently has the focus. This might be null. More...
 
static bool UseAndroidTTS ()
 
static bool UseiOSTTS ()
 
static bool UseWindowsTTS ()
 
static void RecalculateUIElementsOrder (GameObject parent=null)
 This function refreshes the internal order in which the UI elements are stepped through by their on screen position. You might want to call this function if you have an intro animation that builds up your menu screen and the animation moves the buttons, labels etc around. If you find the order in which the menu is traversed is wrong, this function should be called after the animation is done and it will recalculate the order based on the current positions of the elements.

You should provide the parent of the top most object that moved, to make sure to include all containers underneath. If you don't specify a parent, this function will recalculate ALL containers currently in the scene, which is considerably slower. More...
 
static int GetSpeechRate ()
 Get the current speech rate in the range from 1 to 100. The plugin will take care of loading and saving the speech rate. More...
 
static int SetSpeechRate (int speechRate)
 Set the speech rate in the range 1 to 100. Not supported on all platforms. The speech rate will not affect VoiceOver. If your app is only using VoiceOver, you don't need to touch this at all. If the rate is out of range, it will be clamped to a valid value. Function will return the new (capped) value. The plugin will take care of loading and saving the speech rate. More...
 
static void StopSpeaking ()
 
static string Localize (string key)
 This function is called from the Accessible UI component if the Is Localization Key checkbox is ticked. More...
 
static bool IsVoiceOverAllowed ()
 
static string FormatNumberToCurrentLocale (int intNumber)
 Converts an integer number into a string and adds in separators between thousands to help the voice output read the numbers correctly. The separators are culture specific either commas or points.
Example: While the US uses commas to separate thousands (1,200.00), most European countries use dots (1.200,00). More...
 

Public Attributes

bool m_DefaultState = false
 The state for accessibility on the very first launch of your app. Leave this at false unless this is an app purely for the sight impaired. More...
 
bool m_AutoTurnOnIfScreenReaderDetected = true
 Automatically turn on accessibility if active NVDA/VoiceOver/TalkBack is detected.
 
bool m_RecheckAutoEnablingOnResume = false
 
bool m_HandleUI = true
 If true (Default), the manager will block direct touch to the screen. The plugin listens for UI control gestures, such as left and right swipe. Buttons will not be selectable with single tap anymore. Set this to false if you don't want this part active.
 
bool m_HandleMagicGestures = true
 If true, will recognize magic gestures. for functions like Back, Exit and Pause, and call the appropriate callbacks. This can be active even if the UI handling is disabled.
 
bool m_ExploreByTouch = true
 Reads out the UI element that is under the user's finger. If m_HandleUI is false, this setting will be ignored. As this is a standard accessibility feature on smart phones, do not turn this off unless you have a good reason.
 
bool m_ReadDisabledInteractables = true
 Reads out disabled but visible interactive UI elements. This means buttons, toggles and sliders will be read out, even when they are disabled (but they must be visible). The plugin will read out "Disabled" after the name. Default is true, as this emulates the behavior from iOS VoiceOver. More...
 
bool m_CyclicMenus = false
 When reaching the last element on the screen, the focus will jump back around to the first element if this is set to true. By default, this is false, which triggers a sound effect when the border of the screen is reached. More...
 
bool m_WindowsUseMouseSwipes = false
 
bool m_WindowsUseExploreByTouch = false
 
bool m_EditorOverride = false
 Quick way to enable/disable the plugin during development in Editor only. This variable will be ignored in any standalone builds. More...
 
bool m_EditorEnabledState = false
 
bool m_WindowsTTS = true
 
int m_WindowsTTSVolume = 100
 
bool m_WindowsUseKeys = true
 
bool m_AndroidTTS = true
 
bool m_AndroidUseUpAndDownForElements = false
 
bool m_iOSTTS = true
 
AudioClip m_UINavigationClick = null
 SFX when the UI element is changed
 
AudioClip m_UIInteract = null
 SFX when a button is pressed
 
AudioClip m_UIFocusEnter = null
 SFX when an element receives exclusive focus, such as a slider
 
AudioClip m_UIFocusLeave = null
 SFX when an element loses exclusive focus, such as a slider
 
AudioClip m_UIBoundsReached = null
 SFX when navigation reaches the end of the screen
 
AudioClip m_UIPopUpOpen = null
 SFX when popup opens
 
AudioClip m_UIPopUpClose = null
 SFX when popup closes
 
AudioSource m_AudioPlayer = null
 
AudioSource m_SFXPlayer = null
 
RectTransform m_Frame = null
 
GameObject m_FrameTemplate = null
 
GameObject m_TouchBlocker = null
 
Text m_DebugOutputLabel = null
 
bool m_AllowVoiceOverGlobal = true
 
float m_DoubleTapTime = 0.2f
 Maximum delay for a second tap to occur to still trigger a double tap. This value also influences the delay in which Explore By Touch is triggered, so do not raise this value arbitrarily.
 

Static Public Attributes

static string PluginVersion = "1.0.2"
 
static float PluginVersionAsFloat = 1.02f
 

Detailed Description

This is the main object to handle all the accessibility in an app. Please use the premade Accessibility Manager prefab.

Member Function Documentation

static void UAP_AccessibilityManager.ActivateContainer ( AccessibleUIGroupRoot  container,
bool  activate 
)
static

Called by a UI container to make its content (un-)available for interaction. You don't need to call this function from your own code unless you write a custom implementation of AccessibleUIGroupRoot class.

Parameters
containerThe UI container containing the accessible UI elements.
activateWhether to enable or disable the elements.
static void UAP_AccessibilityManager.BlockInput ( bool  block,
bool  stopSpeakingOnBlock = true 
)
static

This function temporarily blocks input from users to the Accessibility System. Use this to have the accessibility plugin ignore any input from users, but keep the touch blocker active that prevents blind users from accidentally hitting any of your UI elements.

This function is useful if you have a native dialog open, if you want to wait for a sound or animation to finish, or need an announcement to be done before you accept user input again.

If the Accessibility Plugin is inactive or paused, or is not set to handle UI this will have no effect.
This will not stop speech from playing, so you can still use the TTS functionality. Use this instead of ::PauseAccessibility if you still need speech.

Parameters
blocktrue if you want to suspend the input, false to restore
static void UAP_AccessibilityManager.EnableAccessibility ( bool  enable,
bool  readNotification = false 
)
static

Use this to completely enable/disable the accessibility plugin. If accessibility is disabled, there will be no reaction to any user input, calls to Say() will be ignored, and calls to PauseAccessibility() will have no effect.
Use this to turn on/off accessibility via your app's menu.
You can also use the Plugin Toggle component to do this automatically. See Plugin Toggle Documentation.

Note that the user can still turn on accessibility via the three finger triple tap. Disable this Magic Gesture individually if your want this to be disabled too. This is inadvisable though, as it leaves blind users who accidentally turn off accessibility with no option of turning it back on.

Parameters
enablewheter to enable or disable plugin
readNotificationif true, the plugin will announce the state change via TTS, so that the user gets audio confirmation
static string UAP_AccessibilityManager.FormatNumberToCurrentLocale ( int  intNumber)
static

Converts an integer number into a string and adds in separators between thousands to help the voice output read the numbers correctly. The separators are culture specific either commas or points.
Example: While the US uses commas to separate thousands (1,200.00), most European countries use dots (1.200,00).

Parameters
intNumber
Returns
static GameObject UAP_AccessibilityManager.GetCurrentFocusObject ( )
static

Retrieve the GameObject containing the UI element that currently has the focus. This might be null.

Returns
static int UAP_AccessibilityManager.GetSpeechRate ( )
static

Get the current speech rate in the range from 1 to 100. The plugin will take care of loading and saving the speech rate.

Returns
speech rate
static bool UAP_AccessibilityManager.IsActive ( )
static

Returns whether Accessibility mode is enabled and unpaused. If the plugin is enabled, but currently paused, this function will return true. Please use IsEnabled() if you want to query whether the plugin is enabled at all.

Returns
true if plugin is enabled and unpaused
static bool UAP_AccessibilityManager.IsCurrentPlatformSupported ( )
static

Convenience function to check whether the current platform is officially supported. Has no further effect on the plugin.

Returns
static bool UAP_AccessibilityManager.IsEnabled ( )
static

Returns whether Accessibility mode is enabled or not. This does not consider paused state. If the Accessibility mode is active, but currently paused, this function will still return true. If you need to know whether the mode is active, query IsActive() instead.

Returns
true if the plugin is active, false otherwise
static bool UAP_AccessibilityManager.IsSpeaking ( )
static

This function returns whether there is currently voice audio playing. This includes Text-To-Speech voice or pre-recorded audio clips, if those were provided. It does not include sound effects.

Apps can use this if they want to wait for everything to be finished before triggering more audio. Works especially well in combination with temporary preventing input via BlockInput during the wait, to make sure not further voice output is started.

Please note that the function is not 100% exact. Depending on the TTS system, it isn't always possible to find out whether the voice is still speaking. So instead the system estimates an approximate speaking duration.

Returns
static bool UAP_AccessibilityManager.IsTalkBackEnabled ( )
static

Is Google TalkBack activated (on or suspended). It is impossible to tell whether TalkBack is currently suspended, as the system still reports it as active in that case.

Returns
Returns true if TalkBack is either active or currently suspended, and false if it is inactive.
static string UAP_AccessibilityManager.Localize ( string  key)
static

This function is called from the Accessible UI component if the Is Localization Key checkbox is ticked.

If NGUI support is enabled, this function will use NGUI's inhouse localization function to localize the text. In all other cases, you can use this function to hook up your own localization system/plugin and make the appropriate call.

Parameters
key
Returns
static void UAP_AccessibilityManager.PauseAccessibility ( bool  pause)
static

Temporarily suspend the core accessibility features. This is useful if your game requires direct touch input for gameplay. You can call this function regardless of whether the accessibility mode is enabled or not (if it is not, it will NOT enable it). There is no need to query the state of the plugin with IsEnabled() first. When accessibility is suspended but not disabled, the plugin will continue to listen to magic gestures (unless that is disabled in the Settings). Please see the documentation for a more thorough explanation. To turn off the accessibility completely, use EnableAccessibility() instead.

Parameters
pausetrue to pause, false to resume
static void UAP_AccessibilityManager.RecalculateUIElementsOrder ( GameObject  parent = null)
static

This function refreshes the internal order in which the UI elements are stepped through by their on screen position. You might want to call this function if you have an intro animation that builds up your menu screen and the animation moves the buttons, labels etc around. If you find the order in which the menu is traversed is wrong, this function should be called after the animation is done and it will recalculate the order based on the current positions of the elements.

You should provide the parent of the top most object that moved, to make sure to include all containers underneath. If you don't specify a parent, this function will recalculate ALL containers currently in the scene, which is considerably slower.

Parameters
parent
static void UAP_AccessibilityManager.RegisterAccessibilityModeChangeCallback ( OnAccessibilityModeChanged  func)
static

Get notified when the accessibility mode turns on/off. The Accessibility Plugin can be enabled by the user with a three finger triple tap at any time. In addition, if the app is resumed from suspension, and a screen reader is now detected and the plugin wasn't enabled yet, it will then enable itself as well. This serves as a safeguard for blind people that accidentally disable accessibility mode and exit and re-enter the app in hopes to restore accessibility mode.

Parameters
funcfunction to receive the callback
static void UAP_AccessibilityManager.RegisterOnPauseToggledCallback ( OnPauseToggleCallbackFunc  func)
static

Register to be notified when the user made the Pause gesture / Magic Tap. See the documentation on Magic Gestures.

The plugin can only detect that the gesture was triggered. It does not maintain your app's paused state (because you might have other things/buttons trigger a pause). That's why there is no bool parameter to the callback function Do not forget to call UnregisterOnPauseToggledCallback() when your object gets destroyed.

Parameters
funcMember function to call when the gesture is detected.
static void UAP_AccessibilityManager.RegisterOnThreeFingerDoubleTapCallback ( OnTapEvent  func)
static

Register to be notified when the user tapped the screen twice with three fingers. Using this callback ensures that the user did not intend to do a three finger triple tap. It is fired only after the double tap threshold time is up.

Parameters
funcMember function to call when the gesture is detected.
static void UAP_AccessibilityManager.RegisterOnThreeFingerSingleTapCallback ( OnTapEvent  func)
static

Register to be notified when the user tapped the screen once with three fingers. Using this callback ensures that the user did not intend to do a three finger double or triple tap. It is fired only after the double tap threshold time is up.

Parameters
funcMember function to call when the gesture is detected.
static void UAP_AccessibilityManager.RegisterOnTwoFingerSingleTapCallback ( OnTapEvent  func)
static

Register to be notified when the user tapped the screen once with two fingers. Using this callback ensures that the user did not intend to do a magic tap (two finger double tap). It is fired only after the double tap threshold time is up.

Parameters
funcMember function to call when the gesture is detected.
static void UAP_AccessibilityManager.Say ( string  textToSay,
bool  canBeInterrupted = true,
bool  allowVoiceOver = true,
UAP_AudioQueue.EInterrupt  interrupts = UAP_AudioQueue.EInterrupt.Elements 
)
static

Say something using platform independent Text To Speech. If you disabled TTS in the settings, or TTS is not available on the current platform, the call will be ignored.

Parameters
textToSaystring to speak using Text-to-Speech
canBeInterruptedYou can prevent interuption and force this line to be finished, regardless of what the user does. Generally not recommended.
allowVoiceOveriOS only - whether regular VoiceOver (if enabled) should speak the text. This should only be set to false if you also offer speech settings. It can make sense to suppress VoiceOver if you really (really!) need to prevent the game audio volume being temporarily lowered for the speech. Don't touch this otherwise, as blind users much prefer to be able to use their own, custom VoiceOver voice and speech settings. (Did I stress this point enough?)
interruptsBy default, this call will interrupt regular UI announcements, but not previous calls to this Say() function from within your own code. Change to ALL to interrupt everything.
static int UAP_AccessibilityManager.SetSpeechRate ( int  speechRate)
static

Set the speech rate in the range 1 to 100. Not supported on all platforms. The speech rate will not affect VoiceOver. If your app is only using VoiceOver, you don't need to touch this at all. If the rate is out of range, it will be clamped to a valid value. Function will return the new (capped) value. The plugin will take care of loading and saving the speech rate.

Returns
new speech rate
static void UAP_AccessibilityManager.SetTwoFingerSwipeDownHandler ( OnTapEvent  func)
static

Overrides the regular two finger swipe down function, which is Read-From-Current-Element. Use this to handle the gesture yourself. This will stop the Read-From-Current-Element feature from working until ::ResetTwoFingerSwipeDownHandler is called.

This can be very useful during gameplay, if the gesture is used to read out stats or help instead.

Parameters
funcMember function to call when the gesture is detected.
static void UAP_AccessibilityManager.SetTwoFingerSwipeUpHandler ( OnTapEvent  func)
static

Overrides the regular two finger swipe up function, which is Read-From-Top. Use this to handle the gesture yourself. This will stop the Read-From-Top feature from working until ::ResetTwoFingerSwipeUpHandler is called.

This can be very useful during gameplay, if the gesture is used to read out stats or help instead.

Parameters
funcMember function to call when the gesture is detected.
static void UAP_AccessibilityManager.UnregisterAccessibilityModeChangeCallback ( OnAccessibilityModeChanged  func)
static

Stop receiving notifications when the accessibility mode state changes.

Parameters
functhe callback function that should no longer receive calls
static void UAP_AccessibilityManager.UnregisterOnPauseToggledCallback ( OnPauseToggleCallbackFunc  func)
static

Unregister from notifications when the user made the Pause gesture / Magic Tap. See the documentation on Magic Gestures.

Parameters
funcMember function that was registered.
static void UAP_AccessibilityManager.UnregisterOnThreeFingerDoubleTapCallback ( OnTapEvent  func)
static

Unregister from callback for three finger double taps.

Parameters
funcMember function that was registered.
static void UAP_AccessibilityManager.UnregisterOnThreeFingerSingleTapCallback ( OnTapEvent  func)
static

Unregister from callback for three finger single taps.

Parameters
funcMember function that was registered.
static void UAP_AccessibilityManager.UnregisterOnTwoFingerSingleTapCallback ( OnTapEvent  func)
static

Unregister from callback for two finger single taps.

Parameters
funcMember function that was registered.

Member Data Documentation

bool UAP_AccessibilityManager.m_CyclicMenus = false

When reaching the last element on the screen, the focus will jump back around to the first element if this is set to true. By default, this is false, which triggers a sound effect when the border of the screen is reached.

bool UAP_AccessibilityManager.m_DefaultState = false

The state for accessibility on the very first launch of your app. Leave this at false unless this is an app purely for the sight impaired.

bool UAP_AccessibilityManager.m_EditorOverride = false

Quick way to enable/disable the plugin during development in Editor only. This variable will be ignored in any standalone builds.

bool UAP_AccessibilityManager.m_ReadDisabledInteractables = true

Reads out disabled but visible interactive UI elements. This means buttons, toggles and sliders will be read out, even when they are disabled (but they must be visible). The plugin will read out "Disabled" after the name. Default is true, as this emulates the behavior from iOS VoiceOver.


The documentation for this class was generated from the following file: