worldspacekeyboard - eisclimber/ExPresS-XR GitHub Wiki

WorldSpaceKeyboard

Class in ExPresSXR.UI

Inherits from UnityEngine.MonoBehaviour

Summary

A world space UI element representing keyboard with an input field for XR. It can be configured to match any set of characters or even longer string sequences. Keyboards of the German and English key layouts, and a numpad can be created directly from the GameObject-Menu.

The keyboard can have a Caps-key which is interpreted determined by capsMode.
It can either be:

  • Toggle: Pressing Caps will change between upper to lower and keep it until pressed again.
  • OneCharUpper: Pressing Caps will change the next character to upper, then go back to lower
  • AlwaysUpper: The caps does not have an effect. All characters are in upper case.
  • AlwaysLower: The caps does not have an effect. All characters are in lower case.

To make a new custom Keyboard create a Canvas Object and add a WorldSpaceKeyboards-Component. Then place all Buttons and connect the Buttons with their OnPressed-Event with the WorldSpaceKeyboard.appendToText()-function passing the text of the button as parameter. For the deletion of the last character, clearing or confirming the text simply connect their respective functions instead. If the current text should be shown, add a TMP_InputField and drag it into the property of the WorldSpaceKeyboards.

public class WorldSpaceKeyboard : MonoBehaviour

Fields

Name Description
OnTextChanged Event invoked when the text was changed, providing the new text.
OnTextEntered Event invoked when the text was confirmed, providing the final text.

Methods

Name Description
AppendLineBreak() Adds a linebreak "\n" to the text.
AppendToText(string) Appends the string to the displayed text.
ChangeCapsActive(bool) Explicit setter function for setting caps active so we can connect use a named reference.
ClearText() Clears text displayed in the keyboard.
ConfirmText() Confirms the text input.
RemoveLastFromText() Removes the last character from the text, but keeping possible pre- and suffixes.
ToggleCapsActive() Toggles the caps active state.

Properties

Name Description
CapsActive Whether or not the caps/shift button is currently active. The behavior depends on the selected CapsMode.
CapsMode Defines how the caps/shift button behaves.
Confirmable If the text is confirmable.
Empty Returns true if the text is empty. Use this to resolve some kinks with TMP texts.
InputDisabled Whether or not the keyboard input is currently disabled. This will make all buttons non-interactable and also disable the input field.
InputText The current text input of the keyboard.
TextPrefix A prefix that is always added to the displayed text but is not considered part of the input.
Can be used to e.g. display currency symbols like EUR 100.
TextSuffix A suffix that is always added to the displayed text but is not considered part of the input.
Can be used to e.g. display currency symbols like 100 €.
⚠️ **GitHub.com Fallback** ⚠️