Initial commit

This commit is contained in:
Thorbjoern
2025-05-26 00:46:28 +02:00
commit e5bca03433
3896 changed files with 1434297 additions and 0 deletions
@@ -0,0 +1,18 @@
#if TEXT_MESH_PRO_PRESENT || (UGUI_2_0_PRESENT && UNITY_6000_0_OR_NEWER)
namespace UnityEngine.XR.Interaction.Toolkit.Samples.SpatialKeyboard.KeyFunctions
{
/// <summary>
/// Key function used to hide the keyboard.
/// </summary>
[CreateAssetMenu(fileName = "Hide Function", menuName = "XR/Spatial Keyboard/Hide Key Function", order = 1)]
public class HideFunction : KeyFunction
{
/// <inheritdoc />
public override void ProcessKey(XRKeyboard keyboardContext, XRKeyboardKey key)
{
if (keyboardContext != null)
keyboardContext.Close(false);
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 58528143acafcd44e93258c8e6a59dc5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,18 @@
#if TEXT_MESH_PRO_PRESENT || (UGUI_2_0_PRESENT && UNITY_6000_0_OR_NEWER)
namespace UnityEngine.XR.Interaction.Toolkit.Samples.SpatialKeyboard.KeyFunctions
{
/// <summary>
/// Key function used to send a key code for the keyboard to process.
/// </summary>
[CreateAssetMenu(fileName = "Key Code Function", menuName = "XR/Spatial Keyboard/Key Code Key Function", order = 1)]
public class KeyCodeFunction : KeyFunction
{
/// <inheritdoc />
public override void ProcessKey(XRKeyboard keyboardContext, XRKeyboardKey key)
{
if (keyboardContext != null)
keyboardContext.ProcessKeyCode(key.keyCode);
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 92861f72e977a244cb0be6d8410a8d99
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,18 @@
#if TEXT_MESH_PRO_PRESENT || (UGUI_2_0_PRESENT && UNITY_6000_0_OR_NEWER)
namespace UnityEngine.XR.Interaction.Toolkit.Samples.SpatialKeyboard.KeyFunctions
{
/// <summary>
/// Key function used to update the keyboard layout.
/// </summary>
[CreateAssetMenu(fileName = "Layout Function", menuName = "XR/Spatial Keyboard/Layout Key Function", order = 1)]
public class LayoutFunction : KeyFunction
{
/// <inheritdoc />
public override void ProcessKey(XRKeyboard keyboardContext, XRKeyboardKey key)
{
if (keyboardContext != null)
keyboardContext.UpdateLayout(key.GetEffectiveCharacter());
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0f25471b9f361d64ba3aebe064d73092
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,73 @@
#if TEXT_MESH_PRO_PRESENT || (UGUI_2_0_PRESENT && UNITY_6000_0_OR_NEWER)
namespace UnityEngine.XR.Interaction.Toolkit.Samples.SpatialKeyboard.KeyFunctions
{
/// <summary>
/// Key function used to process shift and caps lock functionality.
/// </summary>
[CreateAssetMenu(fileName = "Shift Function", menuName = "XR/Spatial Keyboard/Shift Key Function", order = 1)]
public class ShiftFunction : KeyFunction
{
[SerializeField]
Sprite m_CapsLockDisplayIcon;
public Sprite capsLockDisplayIcon
{
get => m_CapsLockDisplayIcon;
set => m_CapsLockDisplayIcon = value;
}
/// <inheritdoc />
public override Sprite GetDisplayIcon(XRKeyboard keyboardContext, XRKeyboardKey key)
{
// This method won't be called unless OverrideDisplayIcon below returns true,
// so no need for logic to return a shift display icon, which is already set up
// as the default in the UI.
return m_CapsLockDisplayIcon;
}
/// <inheritdoc />
public override bool OverrideDisplayIcon(XRKeyboard keyboardContext, XRKeyboardKey key)
{
return keyboardContext != null && keyboardContext.capsLocked;
}
/// <inheritdoc />
public override void ProcessKey(XRKeyboard keyboardContext, XRKeyboardKey key)
{
if (keyboardContext == null)
return;
var keyCode = KeyCode.LeftShift;
// Check the caps lock state of the keyboard. If they key is shifted, check if there is a double click.
if (keyboardContext.capsLocked || (keyboardContext.shifted && key.timeSinceLastClick < keyboardContext.doubleClickInterval))
keyCode = KeyCode.CapsLock;
keyboardContext.ProcessKeyCode(keyCode);
}
/// <inheritdoc />
public override void PostprocessKey(XRKeyboard keyboardContext, XRKeyboardKey key)
{
base.PostprocessKey(keyboardContext, key);
RefreshKeyHighlight(keyboardContext, key);
}
/// <inheritdoc />
public override void ProcessRefreshDisplay(XRKeyboard keyboardContext, XRKeyboardKey key)
{
base.ProcessRefreshDisplay(keyboardContext, key);
RefreshKeyHighlight(keyboardContext, key);
}
protected void RefreshKeyHighlight(XRKeyboard keyboardContext, XRKeyboardKey key)
{
if (keyboardContext == null)
return;
var highlight = keyboardContext.capsLocked || keyboardContext.shifted;
key.EnableHighlight(highlight);
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cad704687d7908f42b71e1e4516c590a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,18 @@
#if TEXT_MESH_PRO_PRESENT || (UGUI_2_0_PRESENT && UNITY_6000_0_OR_NEWER)
namespace UnityEngine.XR.Interaction.Toolkit.Samples.SpatialKeyboard.KeyFunctions
{
/// <summary>
/// Key function used to update the keyboard text with a string value.
/// </summary>
[CreateAssetMenu(fileName = "Value Key Function", menuName = "XR/Spatial Keyboard/Value Key Function", order = 1)]
public class ValueKeyFunction : KeyFunction
{
/// <inheritdoc />
public override void ProcessKey(XRKeyboard keyboardContext, XRKeyboardKey key)
{
if (keyboardContext != null)
keyboardContext.UpdateText(key.GetEffectiveCharacter());
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4857d519405a3874cb91aea6424e314d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: