Enable or disable pointer with speech

This commit is contained in:
Santiago Lo Coco 2024-10-19 22:36:21 +02:00
parent a7bac79ce5
commit 2e6e03f53b
8 changed files with 335 additions and 1 deletions

View File

@ -112,7 +112,7 @@ MonoBehaviour:
inputActionRulesProfile: {fileID: 11400000, guid: 03945385d89102f41855bc8f5116b199, type: 2}
pointerProfile: {fileID: 11400000, guid: 48aa63a9725047b28d4137fd0834bc31, type: 2}
gesturesProfile: {fileID: 11400000, guid: bd7829a9b29409045a745b5a18299291, type: 2}
speechCommandsProfile: {fileID: 11400000, guid: e8d0393e66374dae9646851a57dc6bc1, type: 2}
speechCommandsProfile: {fileID: 11400000, guid: 252528ae2d3a4fc4eba4752b90de5e7d, type: 2}
enableControllerMapping: 1
controllerMappingProfile: {fileID: 11400000, guid: 39ded1fd0711a0c448413d0e1ec4f7f3, type: 2}
controllerVisualizationProfile: {fileID: 11400000, guid: 345c06fdf3732db46b96299bd3cba653, type: 2}

View File

@ -0,0 +1,79 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
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: db393d206eab4604ab74278cb6cda355, type: 3}
m_Name: MixedRealityPointerProfile
m_EditorClassIdentifier:
isCustomProfile: 1
pointingExtent: 10
pointingRaycastLayerMasks:
- serializedVersion: 2
m_Bits: 4294967291
debugDrawPointingRays: 0
debugDrawPointingRayColors:
- {r: 1, g: 0.58280706, b: 0, a: 1}
- {r: 0.86426115, g: 1, b: 0, a: 1}
- {r: 0, g: 1, b: 0.2163105, a: 1}
- {r: 0, g: 0.3028021, b: 1, a: 1}
- {r: 0.44855833, g: 0, b: 1, a: 1}
gazeCursorPrefab: {fileID: 1000012072213228, guid: 5b3e2856904e43c680f84f326861032a, type: 3}
gazeProviderType:
reference: Microsoft.MixedReality.Toolkit.Input.GazeProvider, Microsoft.MixedReality.Toolkit.Services.InputSystem
useHeadGazeOverride: 0
isEyeTrackingEnabled: 0
pointerOptions:
- controllerType: 5167
handedness: 255
pointerPrefab: {fileID: 1247086986094436, guid: d5b94136462644c9873bb3347169ae7e, type: 3}
prioritizedLayerMasks:
- serializedVersion: 2
m_Bits: 4294967291
- controllerType: 5167
handedness: 255
pointerPrefab: {fileID: 1196247974088106, guid: c4fd3c6fc7ff484eb434775066e7f327, type: 3}
prioritizedLayerMasks:
- serializedVersion: 2
m_Bits: 4294967291
- controllerType: 256
handedness: 7
pointerPrefab: {fileID: 1247086986094436, guid: 51e60b8742bc47640923ac9e75ea74e9, type: 3}
prioritizedLayerMasks:
- serializedVersion: 2
m_Bits: 4294967291
- controllerType: 512
handedness: 7
pointerPrefab: {fileID: 1247086986094436, guid: 31d81f88cf3f71d4b8392ded50df3f05, type: 3}
prioritizedLayerMasks:
- serializedVersion: 2
m_Bits: 4294967291
- controllerType: 5167
handedness: 7
pointerPrefab: {fileID: 1507865967819406, guid: 38b548c6a2c270545a383296ad2bc4d5, type: 3}
prioritizedLayerMasks:
- serializedVersion: 2
m_Bits: 4294967291
- controllerType: 5167
handedness: 7
pointerPrefab: {fileID: 1507865967819406, guid: c2fde7a8938065b459cff79b8ed89393, type: 3}
prioritizedLayerMasks:
- serializedVersion: 2
m_Bits: 51
- controllerType: 2048
handedness: 7
pointerPrefab: {fileID: 1247086986094436, guid: 039b325c9e8fd0545a0475fd4aa35b10, type: 3}
prioritizedLayerMasks:
- serializedVersion: 2
m_Bits: 4294967291
pointerMediator:
reference: Microsoft.MixedReality.Toolkit.Input.DefaultPointerMediator, Microsoft.MixedReality.Toolkit.SDK
primaryPointerSelector:
reference: Microsoft.MixedReality.Toolkit.Input.DefaultPrimaryPointerSelector,
Microsoft.MixedReality.Toolkit.SDK

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fdfb208c60919af48b98ceb96d18671e
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,25 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
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: 1f18fec9b55c4f818e284af454161962, type: 3}
m_Name: MixedRealitySpeechCommandsProfile
m_EditorClassIdentifier:
isCustomProfile: 1
startBehavior: 0
recognitionConfidenceLevel: 1
speechCommands:
- localizationKey:
keyword: Pointer
keyCode: 0
action:
id: 0
description: None
axisConstraint: 0

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 252528ae2d3a4fc4eba4752b90de5e7d
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -654,6 +654,8 @@ Transform:
m_Children:
- {fileID: 1555317771}
- {fileID: 2137857638}
- {fileID: 704152376}
- {fileID: 2018722011}
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -662,6 +664,83 @@ GameObject:
m_CorrespondingSourceObject: {fileID: 2311476450002457713, guid: 4410a2a17e71713438d8cf4ebc93d9a4, type: 3}
m_PrefabInstance: {fileID: 1725194923}
m_PrefabAsset: {fileID: 0}
--- !u!1 &704152375
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 704152376}
- component: {fileID: 704152377}
- component: {fileID: 704152378}
m_Layer: 0
m_Name: ConfigurePointer
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &704152376
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 704152375}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0.02267203, y: -0.03312298, z: 1.1904888}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 425776887}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &704152377
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 704152375}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6ed9795fceba7ff40ba7002e18a35674, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &704152378
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 704152375}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 45b3eff181cc4244a8a14234096e62fd, type: 3}
m_Name:
m_EditorClassIdentifier:
isFocusRequired: 0
keywords:
- keyword: Pointer
response:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 704152377}
m_TargetAssemblyTypeName: ConfigurePointer, Assembly-CSharp
m_MethodName: ToggleHandRayPointer
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
persistentKeywords: 0
speechConfirmationTooltipPrefab: {fileID: 8046114618238072051, guid: 271778f6c957b524981067a81d238394, type: 3}
--- !u!1 &705507993
GameObject:
m_ObjectHideFlags: 0
@ -2973,6 +3052,83 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1962870114}
m_CullTransparentMesh: 1
--- !u!1 &2018722010
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2018722011}
- component: {fileID: 2018722013}
- component: {fileID: 2018722012}
m_Layer: 0
m_Name: SpeechHandler
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2018722011
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2018722010}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0.02267203, y: -0.03312298, z: 1.1904888}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 425776887}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &2018722012
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2018722010}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 45b3eff181cc4244a8a14234096e62fd, type: 3}
m_Name:
m_EditorClassIdentifier:
isFocusRequired: 0
keywords:
- keyword: Pointer
response:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 2018722010}
m_TargetAssemblyTypeName:
m_MethodName:
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName:
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
persistentKeywords: 0
speechConfirmationTooltipPrefab: {fileID: 8046114618238072051, guid: 271778f6c957b524981067a81d238394, type: 3}
--- !u!114 &2018722013
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2018722010}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6ed9795fceba7ff40ba7002e18a35674, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!21 &2059116078
Material:
serializedVersion: 8

View File

@ -0,0 +1,47 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Microsoft.MixedReality.Toolkit;
using Microsoft.MixedReality.Toolkit.Utilities;
using Microsoft.MixedReality.Toolkit.Input;
public class ConfigurePointer : MonoBehaviour
{
void Start()
{
// PointerUtils.SetMotionControllerRayPointerBehavior(PointerBehavior.AlwaysOff);
// PointerUtils.SetGazePointerBehavior(PointerBehavior.AlwaysOff);
// PointerUtils.SetHandRayPointerBehavior(PointerBehavior.AlwaysOff); --> This is the one we want to disable/enable
}
// make a toggle method for the hand ray pointer. use a bool to keep track of the state
// if the bool is true, disable the hand ray pointer
// if the bool is false, enable the hand ray pointer
// by default it is true.
private bool handRayPointerEnabled = true;
public void ToggleHandRayPointer()
{
if (handRayPointerEnabled)
{
DisableHandRayPointer();
handRayPointerEnabled = false;
}
else
{
EnableHandRayPointer();
handRayPointerEnabled = true;
}
}
public void EnableHandRayPointer()
{
PointerUtils.SetHandRayPointerBehavior(PointerBehavior.AlwaysOn);
}
public void DisableHandRayPointer()
{
PointerUtils.SetHandRayPointerBehavior(PointerBehavior.AlwaysOff);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6ed9795fceba7ff40ba7002e18a35674
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: