From badf592a2e0651a8c10e8bdda925055d767b5fd3 Mon Sep 17 00:00:00 2001 From: Udayshankar Ravikumar Date: Sun, 8 Dec 2024 23:08:49 +0530 Subject: [PATCH] v1.0.0-preview.2: Updated docs and some variables. --- .../Scripts/Managers/XRKeyboardManager.cs | 10 ++--- .../Scripts/Movement/SimpleCameraFollower.cs | 2 +- .../Movement/SimpleMovementController.cs | 8 ++-- .../Runtime/Scripts/UI/TextInputField.cs | 2 +- .../Scripts/UI/TextInputFieldVoiceHandler.cs | 41 +++++++++++++++++-- .../com.uralstech.uxr.utilities/package.json | 2 +- UXR.Utilities/Packages/manifest.json | 3 ++ UXR.Utilities/Packages/packages-lock.json | 22 ++++++++++ 8 files changed, 75 insertions(+), 15 deletions(-) diff --git a/UXR.Utilities/Packages/com.uralstech.uxr.utilities/Runtime/Scripts/Managers/XRKeyboardManager.cs b/UXR.Utilities/Packages/com.uralstech.uxr.utilities/Runtime/Scripts/Managers/XRKeyboardManager.cs index eca9797..7c6a7e2 100644 --- a/UXR.Utilities/Packages/com.uralstech.uxr.utilities/Runtime/Scripts/Managers/XRKeyboardManager.cs +++ b/UXR.Utilities/Packages/com.uralstech.uxr.utilities/Runtime/Scripts/Managers/XRKeyboardManager.cs @@ -104,13 +104,13 @@ public class XRKeyboardManager : Singleton /// [Header("Callbacks")] [Tooltip("Called when the keyboard is created.")] - public UnityEvent OnKeyboardCreated = new(); + [FormerlySerializedAs("OnKeyboardCreated")] public UnityEvent OnKeyboardShown = new(); /// /// Called when the keyboard is destroyed. /// [Tooltip("Called when the keyboard is destroyed.")] - public UnityEvent OnKeyboardDestroyed = new(); + [FormerlySerializedAs("OnKeyboardDestroyed")] public UnityEvent OnKeyboardHidden = new(); /// /// The current instance of the . @@ -172,7 +172,7 @@ private void ShowKeyboard() SimpleMovementController.Instance.MovementEnabled = false; SetHandMaterial(TypingHandMaterial); - OnKeyboardCreated.Invoke(); + OnKeyboardShown.Invoke(); } private void HideKeyboard() @@ -191,7 +191,7 @@ private void HideKeyboard() SimpleMovementController.Instance.MovementEnabled = true; SetHandMaterial(NormalHandMaterial); - OnKeyboardDestroyed.Invoke(); + OnKeyboardHidden.Invoke(); } /// @@ -213,7 +213,7 @@ public void SetListener(OVRVirtualKeyboard.ITextHandler listener) /// /// Unbinds the given object from the keyboard. /// - /// The object to unbind from the keyboard. + /// The object to unbind from the keyboard. Must be the same as . public void RemoveListener(OVRVirtualKeyboard.ITextHandler listener) { if (!ReferenceEquals(CurrentListener, listener) || listener == null) diff --git a/UXR.Utilities/Packages/com.uralstech.uxr.utilities/Runtime/Scripts/Movement/SimpleCameraFollower.cs b/UXR.Utilities/Packages/com.uralstech.uxr.utilities/Runtime/Scripts/Movement/SimpleCameraFollower.cs index 502d264..e7a684d 100644 --- a/UXR.Utilities/Packages/com.uralstech.uxr.utilities/Runtime/Scripts/Movement/SimpleCameraFollower.cs +++ b/UXR.Utilities/Packages/com.uralstech.uxr.utilities/Runtime/Scripts/Movement/SimpleCameraFollower.cs @@ -101,7 +101,7 @@ private void LateUpdate() || verticalSeperationDistance < _adjustedLowerHeightOffset || angle > RotationDelayAngle) { - _targetPosition = _playerHeadTransform.position + Quaternion.Euler(0f, _playerHeadTransform.eulerAngles.y, 0f) * Vector3.forward * DistanceOffset + Vector3.up * HeightOffset; + _targetPosition = _playerHeadTransform.position + (Quaternion.Euler(0f, _playerHeadTransform.eulerAngles.y, 0f) * Vector3.forward * DistanceOffset) + (Vector3.up * HeightOffset); _targetRotation = Quaternion.Euler(0f, _playerHeadTransform.rotation.eulerAngles.y, 0f) * Quaternion.Euler(RotationOffset); } diff --git a/UXR.Utilities/Packages/com.uralstech.uxr.utilities/Runtime/Scripts/Movement/SimpleMovementController.cs b/UXR.Utilities/Packages/com.uralstech.uxr.utilities/Runtime/Scripts/Movement/SimpleMovementController.cs index dabdd61..959ac03 100644 --- a/UXR.Utilities/Packages/com.uralstech.uxr.utilities/Runtime/Scripts/Movement/SimpleMovementController.cs +++ b/UXR.Utilities/Packages/com.uralstech.uxr.utilities/Runtime/Scripts/Movement/SimpleMovementController.cs @@ -1,4 +1,5 @@ using UnityEngine; +using UnityEngine.Serialization; using Uralstech.Utils.Singleton; namespace Uralstech.UXR.Utilities @@ -12,18 +13,19 @@ public class SimpleMovementController : DontCreateNewSingleton /// Use this boolean to toggle movement. /// + [Tooltip("Boolean to toggle movement.")] public bool MovementEnabled = true; /// /// The movement speed. /// [Tooltip("The movement speed.")] - public float MoveSpeed = 3f; + [FormerlySerializedAs("MoveSpeed")] public float MovementSpeed = 3f; /// /// Snap turn angle. /// - [Tooltip("Snap turn angle")] + [Tooltip("Snap turn angle.")] public float RotationSnapAngle = 30f; private Transform _playerHeadTransform; @@ -51,7 +53,7 @@ private void FixedUpdate() { Vector2 primaryThumbstick = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick); Vector3 moveDirection = ((_playerHeadTransform.forward * primaryThumbstick.y) + (_playerHeadTransform.right * primaryThumbstick.x)).normalized; - _rigidbody.linearVelocity = new Vector3(moveDirection.x * MoveSpeed, _rigidbody.linearVelocity.y, moveDirection.z * MoveSpeed); + _rigidbody.linearVelocity = new Vector3(moveDirection.x * MovementSpeed, _rigidbody.linearVelocity.y, moveDirection.z * MovementSpeed); } Vector2 secondaryThumbstick = OVRInput.Get(OVRInput.Axis2D.SecondaryThumbstick); diff --git a/UXR.Utilities/Packages/com.uralstech.uxr.utilities/Runtime/Scripts/UI/TextInputField.cs b/UXR.Utilities/Packages/com.uralstech.uxr.utilities/Runtime/Scripts/UI/TextInputField.cs index d6bba1e..10d9714 100644 --- a/UXR.Utilities/Packages/com.uralstech.uxr.utilities/Runtime/Scripts/UI/TextInputField.cs +++ b/UXR.Utilities/Packages/com.uralstech.uxr.utilities/Runtime/Scripts/UI/TextInputField.cs @@ -25,7 +25,7 @@ public class TextInputField : Selectable, IPointerClickHandler, OVRVirtualKeyboa public Action OnTextChanged { get; set; } /// - [field: SerializeField] public bool SubmitOnEnter { get; set; } = true; + [field: SerializeField] public bool SubmitOnEnter { get; set; } = true; /// public bool IsFocused { get; private set; } diff --git a/UXR.Utilities/Packages/com.uralstech.uxr.utilities/Runtime/Scripts/UI/TextInputFieldVoiceHandler.cs b/UXR.Utilities/Packages/com.uralstech.uxr.utilities/Runtime/Scripts/UI/TextInputFieldVoiceHandler.cs index 3f84c6f..9d6dca6 100644 --- a/UXR.Utilities/Packages/com.uralstech.uxr.utilities/Runtime/Scripts/UI/TextInputFieldVoiceHandler.cs +++ b/UXR.Utilities/Packages/com.uralstech.uxr.utilities/Runtime/Scripts/UI/TextInputFieldVoiceHandler.cs @@ -5,15 +5,42 @@ namespace Uralstech.UXR.Utilities { + /// + /// Sister-script to which adds support for voice typing through Meta's Voice SDK. + /// + /// + /// Requires a somewhere in the scene. + /// [AddComponentMenu("Uralstech/UXR/Utilities/UI/Text Input Field Voice Handler"), RequireComponent(typeof(TextInputField))] public class TextInputFieldVoiceHandler : MonoBehaviour { + /// + /// Is the user currently voice typing? + /// public bool IsRecording { get; private set; } = false; + /// + /// The button to toggle voice typing. + /// + [Tooltip("The button to toggle voice typing.")] public Button ToggleButton; + + /// + /// Optional, the icon for that will be changed based on the current recording state. + /// + [Tooltip("Optional, the icon for ToggleButton that will be changed based on the current recording state.")] public Image ToggleButtonIcon; + /// + /// Optional, icon to set for while not recording the user's audio. + /// + [Tooltip("Optional, icon to set for ToggleButtonIcon while not recording the user's audio.")] public Sprite StartRecordingIcon; + + /// + /// Optional, icon to set for while recording the user's audio. + /// + [Tooltip("Optional, icon to set for ToggleButtonIcon while recording the user's audio.")] public Sprite StopRecordingIcon; private TextInputField _inputField; @@ -24,7 +51,9 @@ public class TextInputFieldVoiceHandler : MonoBehaviour private void Start() { ToggleButton.onClick.AddListener(OnToggleRecording); - ToggleButtonIcon.sprite = StartRecordingIcon; + + if (ToggleButtonIcon != null) + ToggleButtonIcon.sprite = StartRecordingIcon; _dictation = FindAnyObjectByType(); _inputField = GetComponent(); @@ -67,9 +96,11 @@ private void StartRecording() Debug.Log($"{nameof(TextInputFieldVoiceHandler)}: Starting dictation."); _previousPartialTranscription = string.Empty; - ToggleButtonIcon.sprite = StopRecordingIcon; IsRecording = true; + if (ToggleButtonIcon != null) + ToggleButtonIcon.sprite = StopRecordingIcon; + VoiceServiceRequestEvents events = new(); events.OnFullTranscription.AddListener(OnFullTranscription); events.OnComplete.AddListener(_ => StopRecording()); @@ -79,9 +110,11 @@ private void StartRecording() private void StopRecording() { Debug.Log($"{nameof(TextInputFieldVoiceHandler)}: Stopping dictation."); - ToggleButtonIcon.sprite = StartRecordingIcon; IsRecording = false; + if (ToggleButtonIcon != null) + ToggleButtonIcon.sprite = StartRecordingIcon; + if (_dictation.Active) _dictation.Deactivate(); } @@ -97,7 +130,7 @@ private void OnPartialTranscription(string transcription, bool overrideRecording _previousPartialTranscription = transcription; } - + private void OnFullTranscription(string transcription) { OnPartialTranscription(transcription, true); diff --git a/UXR.Utilities/Packages/com.uralstech.uxr.utilities/package.json b/UXR.Utilities/Packages/com.uralstech.uxr.utilities/package.json index cb62f82..6e9b3fd 100644 --- a/UXR.Utilities/Packages/com.uralstech.uxr.utilities/package.json +++ b/UXR.Utilities/Packages/com.uralstech.uxr.utilities/package.json @@ -4,7 +4,7 @@ "displayName": "UXR.Utilities", "description": "Random helper scripts I made for Meta Quest XR projects.", "keywords": [ ], - "version": "1.0.0-preview.1", + "version": "1.0.0-preview.2", "unity": "6000.0", "hideInEditor": false, "documentationUrl": "https://uralstech.github.io/UXR.Utilities/", diff --git a/UXR.Utilities/Packages/manifest.json b/UXR.Utilities/Packages/manifest.json index ca27bfd..129298d 100644 --- a/UXR.Utilities/Packages/manifest.json +++ b/UXR.Utilities/Packages/manifest.json @@ -1,14 +1,17 @@ { "dependencies": { "com.meta.xr.sdk.interaction": "71.0.0", + "com.meta.xr.sdk.interaction.ovr": "71.0.0", "com.unity.ide.visualstudio": "2.0.22", "com.unity.test-framework": "1.4.5", "com.unity.xr.oculus": "4.4.0", + "com.unity.modules.ai": "1.0.0", "com.unity.modules.androidjni": "1.0.0", "com.unity.modules.animation": "1.0.0", "com.unity.modules.assetbundle": "1.0.0", "com.unity.modules.audio": "1.0.0", "com.unity.modules.imageconversion": "1.0.0", + "com.unity.modules.particlesystem": "1.0.0", "com.unity.modules.physics": "1.0.0", "com.unity.modules.physics2d": "1.0.0", "com.unity.modules.unitywebrequest": "1.0.0", diff --git a/UXR.Utilities/Packages/packages-lock.json b/UXR.Utilities/Packages/packages-lock.json index 106e21d..e82ff75 100644 --- a/UXR.Utilities/Packages/packages-lock.json +++ b/UXR.Utilities/Packages/packages-lock.json @@ -17,6 +17,16 @@ }, "url": "https://packages.unity.com" }, + "com.meta.xr.sdk.interaction.ovr": { + "version": "71.0.0", + "depth": 0, + "source": "registry", + "dependencies": { + "com.meta.xr.sdk.core": "71.0.0", + "com.meta.xr.sdk.interaction": "71.0.0" + }, + "url": "https://packages.unity.com" + }, "com.meta.xr.sdk.voice": { "version": "71.0.0", "depth": 1, @@ -117,6 +127,12 @@ "com.unity.ugui": "2.0.0" } }, + "com.unity.modules.ai": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, "com.unity.modules.androidjni": { "version": "1.0.0", "depth": 0, @@ -159,6 +175,12 @@ "source": "builtin", "dependencies": {} }, + "com.unity.modules.particlesystem": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, "com.unity.modules.physics": { "version": "1.0.0", "depth": 0,