A keyboard that can be used in any project that supports Unity's XR Interaction Toolkit. Demo scene can be found in Assets/MagicLeap/Runtime/KeyboardExample/Scenes/XRKeyboardExample.unity
Add the following git url to the Unity Package Manager: https://github.com/magicleap/MagicLeapXRKeyboard.git?path=/Packages/MagicLeapXRKeyboard
To have the same interactions as in the example scene, make the following changes:
Force Grab
from the XR Ray InteractorKeep Selected Target Valid
Learn how to create cusom layouts here
Make sure to set the input option in Player Settings to new
.
Packages/Magic Leap XR Keyboard/Runtime/Prefabs/Keyboard Manager.prefab
into the sceneTMPInputFieldTextReceiver.cs
onto any TextMeshPro Input Field you want to use with the KeyboardThe Keyboard prefab is structured in the following way:
KeyboardManager.cs
- Allows users to toggle the Keyboard on and off.Keyboard.cs
- Manages multiple Keyboard Layouts and controls modifier key presses like Shift and Caps LockKeyboardLayout.cs
- groups the Keys and Keyboard Rows and communicates to the Keyboard Builder to generate a new layout if needed.KeyboardBuilder.cs
- consumes JSON data to create the Keyboard Layout objects. The script requires that you assign the Keyboard Key and Keyboard Row prefab. KeyboardKey.cs
- Controls the visual key graphics and inputTo edit the layout:
Magic Leap XR Keyboard uses the following fonts to support unicode characters: | Font | Link |
---|---|---|
Material Symbols | https://github.com/google/material-design-icons | |
Quivira | http://www.quivira-font.com/characters.php |
The shift label is appended with _NEUTRAL _SHIFT and _CAPS at runtime depending on the shift state. A key with the label SHIFT will use the following unicodes (they can be changed in Packages/Magic Leap XR Keyboard/Runtime/Scripts/Keyboard/DataModels/KeyboardCollections.cs ) |
Label Name | Value |
---|---|---|
SHIFT_NEUTRAL | \ue5f2 | |
SHIFT_SHIFT | \uf7ae | |
SHIFT_CAPS | \ue318 | |
SHIFT | \ue5f2 |
There are also other special labels to make it easier to distinguish in the editor | Label Name | Value |
---|---|---|
NUMBERPAD | \uf045 | |
BACKSPACE | \ue14a | |
SPACE | ||
RETURN | \ue31b |
Special Keycodes also exist | Label Name | Value |
---|---|---|
BACKSPACE | \u0008 | |
SPACE | ||
RETURN | \n |
This project is based on UltraLeap's XR Keyboard which is licensed under Apache 2.0 This project is licensed under the Magic Leap Developer License