Skip to content

World Space Keyboard

eisclimber edited this page Nov 3, 2024 · 3 revisions

World Space Keyboard

class in ExPresSXR.UI / Extends MonoBehaviour
GameObject instantiable via ExPresS XRKeyboard - ...

Description

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.

Members

Editor Properties

  • TMP_InputField _inputField: A reference to the TMP_InputField used to show the already input characters.
  • Button _capsButton: A reference to the UnityEngine.UI.Button that toggles the capsActive.

Public Properties

  • string inputText: The currently input text.
  • CapsMode capsMode: The mode of how caps is interpreted
  • bool capsActive: If enabled added characters will be interpreted according to capsMode.

Public Methods

  • void ConfirmText(): Can be used to emit OnTextEntered with the currently entered inputText.
  • void AppendToText(string stringToAppend): Appends another string (or character) to the inputText.
  • void RemoveLastFromText(): Removes the last character from the inputText.
  • void ClearText(): Clears all characters from the inputText.

Events

  • UnityEvent<string> OnTextEntered: Emitted when the input inputText should be confirmed.
  • UnityEvent<string> OnTextChanged: Emitted when a new character/string is added or removed to inputText.

Enums

  • CapsMode: Denotes how the caps key is interpreted.

ExPresS XR Wiki

Tutorial Pages

Code Documentation

Clone this wiki locally