From 2b9e052bd282b16d1f78d58f2d79c6f2aee3eb46 Mon Sep 17 00:00:00 2001 From: Santiago Lo Coco Date: Sun, 10 Nov 2024 22:59:34 +0100 Subject: [PATCH] Add hide speech command --- .../MixedRealitySpeechCommandsProfile.asset | 2 +- Assets/Scenes/WebView.unity | 30 ++++++++++++++++++- Assets/Scripts/EndpointLoader.cs | 10 +++++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/Assets/MixedRealityToolkit.Generated/CustomProfiles/MixedRealitySpeechCommandsProfile.asset b/Assets/MixedRealityToolkit.Generated/CustomProfiles/MixedRealitySpeechCommandsProfile.asset index fd6c250..1b06aee 100644 --- a/Assets/MixedRealityToolkit.Generated/CustomProfiles/MixedRealitySpeechCommandsProfile.asset +++ b/Assets/MixedRealityToolkit.Generated/CustomProfiles/MixedRealitySpeechCommandsProfile.asset @@ -52,7 +52,7 @@ MonoBehaviour: description: None axisConstraint: 0 - localizationKey: - keyword: Select + keyword: Hide keyCode: 0 action: id: 0 diff --git a/Assets/Scenes/WebView.unity b/Assets/Scenes/WebView.unity index de94573..381f9b8 100644 --- a/Assets/Scenes/WebView.unity +++ b/Assets/Scenes/WebView.unity @@ -5831,7 +5831,7 @@ MonoBehaviour: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 963194225} - m_Enabled: 1 + m_Enabled: 0 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: bf98dd1206224111a38765365e98e207, type: 3} m_Name: @@ -9846,6 +9846,34 @@ MonoBehaviour: m_StringArgument: m_BoolArgument: 0 m_CallState: 2 + - keyword: Hide + response: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 491721038} + m_TargetAssemblyTypeName: EndpointLoader, Assembly-CSharp + m_MethodName: ToggleItemsVisibility + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 + - m_Target: {fileID: 2018722013} + m_TargetAssemblyTypeName: UnityEngine.AudioSource, UnityEngine + m_MethodName: PlayOneShot + m_Mode: 2 + m_Arguments: + m_ObjectArgument: {fileID: 8300000, guid: 4075162bd7e8d9b4387ba77aeb751a0d, type: 3} + m_ObjectArgumentAssemblyTypeName: UnityEngine.AudioClip, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 persistentKeywords: 0 speechConfirmationTooltipPrefab: {fileID: 8046114618238072051, guid: 271778f6c957b524981067a81d238394, type: 3} --- !u!82 &2018722013 diff --git a/Assets/Scripts/EndpointLoader.cs b/Assets/Scripts/EndpointLoader.cs index c61ee64..6f7e449 100644 --- a/Assets/Scripts/EndpointLoader.cs +++ b/Assets/Scripts/EndpointLoader.cs @@ -26,6 +26,7 @@ public class EndpointLoader : MonoBehaviour private List instantiatedItems = new List(); private HashSet availableServices = new HashSet(); private float loadTimeout = 10f; + private bool areItemsVisible = true; private const string defaultApiUrl = "http://windows.local:5000/api/endpoints"; private const string defaultEndpoint1 = "http://windows.local:8100/mystream/"; @@ -79,6 +80,15 @@ public class EndpointLoader : MonoBehaviour return cameraTransform.position + cameraTransform.TransformDirection(localOffset); } + public void ToggleItemsVisibility() + { + areItemsVisible = !areItemsVisible; + foreach (var item in instantiatedItems) + { + item.SetActive(areItemsVisible); + } + } + private float GetItemWidth(GameObject item) { RectTransform rectTransform = item.GetComponent();