Skip to content

Commit

Permalink
Improved XRKeyboardManager.
Browse files Browse the repository at this point in the history
  • Loading branch information
Uralstech committed Jan 29, 2025
1 parent 064b437 commit 0f52a70
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 18 deletions.
2 changes: 1 addition & 1 deletion UXR.Utilities/Assets/Resources/OculusRuntimeSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ MonoBehaviour:
colorSpace: 7
requestsVisualFaceTracking: 1
requestsAudioFaceTracking: 1
telemetryProjectGuid: 847aa21b-a3cf-4d40-aa57-a661ac44f2e8
telemetryProjectGuid: bd4bb87d-e79a-4d5c-aa50-ff9419a07db1
bodyTrackingFidelity: 1
bodyTrackingJointSet: 0
34 changes: 33 additions & 1 deletion UXR.Utilities/Assets/XR/XRGeneralSettingsPerBuildTarget.asset
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-386722216451486909
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4c3631f5e58749a59194e0cf6baf6d5, type: 3}
m_Name: Standalone Providers
m_EditorClassIdentifier:
m_RequiresSettingsUpdate: 0
m_AutomaticLoading: 0
m_AutomaticRunning: 0
m_Loaders:
- {fileID: 11400000, guid: be83f6b29a9450847a5af86e3584997d, type: 2}
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
Expand All @@ -12,9 +29,10 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d2dc886499c26824283350fa532d087d, type: 3}
m_Name: XRGeneralSettingsPerBuildTarget
m_EditorClassIdentifier:
Keys: 07000000
Keys: 0700000001000000
Values:
- {fileID: 5667655980897119368}
- {fileID: 3955291714939968411}
--- !u!114 &287996280380131235
MonoBehaviour:
m_ObjectHideFlags: 0
Expand All @@ -32,6 +50,20 @@ MonoBehaviour:
m_AutomaticRunning: 0
m_Loaders:
- {fileID: 11400000, guid: be83f6b29a9450847a5af86e3584997d, type: 2}
--- !u!114 &3955291714939968411
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d236b7d11115f2143951f1e14045df39, type: 3}
m_Name: Standalone Settings
m_EditorClassIdentifier:
m_LoaderManagerInstance: {fileID: -386722216451486909}
m_InitManagerOnStart: 1
--- !u!114 &5667655980897119368
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public class XRKeyboardManager : Singleton<XRKeyboardManager>
/// <summary>
/// The player <see cref="Transform"/>. The keyboard will spawn relative to this object's position. Defaults to first OVRCameraRig found in the scene.
/// </summary>
[Tooltip("The player transform. The keyboard will spawn relative to this object's position. Defaults to first OVRCameraRig found in the scene.")]
[FormerlySerializedAs("_player")] public Transform PlayerTransform;
[Tooltip("The player's head transform. The keyboard will spawn relative to this object's position. Defaults to first Camera.main found in the scene.")]
public Transform PlayerHead;

/// <summary>
/// <see cref="OVRVirtualKeyboard"/> prefab to spawn when needed.
Expand Down Expand Up @@ -115,6 +115,24 @@ public class XRKeyboardManager : Singleton<XRKeyboardManager>
[Tooltip("The hand tracking material when the keyboard is being used.")]
[FormerlySerializedAs("_typingHandMaterial")] public Material TypingHandMaterial;

/// <summary>
/// The initial rotation of the keyboard, relative to the player's forward direction.
/// </summary>
[Tooltip("The initial rotation of the keyboard, relative to the player's forward direction.")]
public Vector3 InitialRotation;

/// <summary>
/// The initial position of the keyboard, when shown, relative to the player.
/// </summary>
[Tooltip("The initial position of the keyboard, when shown, relative to the player.")]
public Vector3 InitialPosition;

/// <summary>
/// The initial distance of the keyboard, when shown, from the player's forward direction.
/// </summary>
[Tooltip("The initial distance of the keyboard, when shown, from the player's forward direction.")]
public float InitialDistance;

/// <summary>
/// Called when the keyboard is created.
/// </summary>
Expand Down Expand Up @@ -151,10 +169,10 @@ protected void Start()

KeyboardPrefab.gameObject.SetActive(false);

if (PlayerTransform == null)
PlayerTransform = FindAnyObjectByType<OVRCameraRig>().transform;
if (PlayerHead == null)
PlayerHead = Camera.main.transform;

KeyboardInstance = Instantiate(KeyboardPrefab, PlayerTransform.position, Quaternion.identity);
KeyboardInstance = Instantiate(KeyboardPrefab, Vector3.zero, Quaternion.identity);

KeyboardInstance.KeyboardHiddenEvent.AddListener(HideKeyboard);
KeyboardInstance.EnterEvent.AddListener(HideKeyboard);
Expand All @@ -181,6 +199,9 @@ private void ShowKeyboard()
{
KeyboardInstance.gameObject.SetActive(true);
KeyboardInstance.TextHandler = CurrentListener;
KeyboardInstance.transform.SetPositionAndRotation(
PlayerHead.position + InitialPosition + (PlayerHead.forward * InitialDistance),
Quaternion.Euler(0f, PlayerHead.rotation.eulerAngles.y, 0f) * Quaternion.Euler(InitialRotation));

Debug.Log("Text handler set in keyboard!");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "UXR.Utilities",
"description": "Random helper scripts I made for Meta Quest XR projects.",
"keywords": [],
"version": "1.1.2",
"version": "1.2.0",
"unity": "6000.0",
"hideInEditor": false,
"documentationUrl": "https://uralstech.github.io/UXR.Utilities/",
Expand Down
4 changes: 2 additions & 2 deletions UXR.Utilities/Packages/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"dependencies": {
"com.meta.xr.sdk.interaction": "71.0.0",
"com.meta.xr.sdk.interaction.ovr": "71.0.0",
"com.meta.xr.sdk.interaction": "72.0.0",
"com.meta.xr.sdk.interaction.ovr": "72.0.0",
"com.unity.ide.visualstudio": "2.0.22",
"com.unity.test-framework": "1.4.5",
"com.unity.xr.oculus": "4.4.0",
Expand Down
10 changes: 5 additions & 5 deletions UXR.Utilities/Packages/packages-lock.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"dependencies": {
"com.meta.xr.sdk.core": {
"version": "71.0.0",
"version": "72.0.0",
"depth": 1,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.meta.xr.sdk.interaction": {
"version": "71.0.0",
"version": "72.0.0",
"depth": 0,
"source": "registry",
"dependencies": {
Expand All @@ -18,12 +18,12 @@
"url": "https://packages.unity.com"
},
"com.meta.xr.sdk.interaction.ovr": {
"version": "71.0.0",
"version": "72.0.0",
"depth": 0,
"source": "registry",
"dependencies": {
"com.meta.xr.sdk.core": "71.0.0",
"com.meta.xr.sdk.interaction": "71.0.0"
"com.meta.xr.sdk.core": "72.0.0",
"com.meta.xr.sdk.interaction": "72.0.0"
},
"url": "https://packages.unity.com"
},
Expand Down
5 changes: 4 additions & 1 deletion UXR.Utilities/ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ PlayerSettings:
androidMinAspectRatio: 1
applicationIdentifier:
Android: com.Uralstech.UXR.Utilities.Demo
Standalone: com.DefaultCompany.3D-Project
Standalone: com.Uralstech.UXR.Utilities.Demo
buildNumber:
Standalone: 0
VisionOS: 0
Expand Down Expand Up @@ -543,6 +543,9 @@ PlayerSettings:
- m_BuildTarget: WebGLSupport
m_APIs: 0b000000
m_Automatic: 1
- m_BuildTarget: WindowsStandaloneSupport
m_APIs: 02000000
m_Automatic: 0
m_BuildTargetVRSettings:
- m_BuildTarget: Standalone
m_Enabled: 0
Expand Down
4 changes: 2 additions & 2 deletions UXR.Utilities/ProjectSettings/ProjectVersion.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
m_EditorVersion: 6000.0.30f1
m_EditorVersionWithRevision: 6000.0.30f1 (62b05ba0686a)
m_EditorVersion: 6000.0.34f1
m_EditorVersionWithRevision: 6000.0.34f1 (5ab2d9ed9190)

0 comments on commit 0f52a70

Please sign in to comment.