Skip to content

Commit bc87b2d

Browse files
Stephen HodgsonStephen Hodgson
authored andcommitted
Merge branch 'HTK-master' into HTK-local
2 parents 369607b + 05903ba commit bc87b2d

File tree

5 files changed

+75
-50
lines changed

5 files changed

+75
-50
lines changed

Assets/HoloToolkit/Input/Animations/Cursor/CursorSimple.controller

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ AnimatorStateTransition:
8181
m_ExitTime: 0.33066684
8282
m_HasExitTime: 0
8383
m_HasFixedDuration: 1
84-
m_InterruptionSource: 0
84+
m_InterruptionSource: 2
8585
m_OrderedInterruption: 1
8686
m_CanTransitionToSelf: 1
8787
--- !u!1101 &1101000011538347200
@@ -156,7 +156,7 @@ AnimatorStateTransition:
156156
m_ExitTime: 0.17148435
157157
m_HasExitTime: 0
158158
m_HasFixedDuration: 1
159-
m_InterruptionSource: 0
159+
m_InterruptionSource: 2
160160
m_OrderedInterruption: 1
161161
m_CanTransitionToSelf: 1
162162
--- !u!1101 &1101000011705696456

Assets/HoloToolkit/Input/Scripts/Voice/KeywordManager.cs

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

4+
using System;
45
using System.Collections.Generic;
5-
using System.Linq;
66
using UnityEngine;
77
using UnityEngine.Events;
88
using UnityEngine.Windows.Speech;
@@ -44,23 +44,36 @@ public enum RecognizerStartBehavior { AutoStart, ManualStart };
4444
public KeywordAndResponse[] KeywordsAndResponses;
4545

4646
private KeywordRecognizer keywordRecognizer;
47-
private Dictionary<string, UnityEvent> responses;
47+
private readonly Dictionary<string, UnityEvent> responses = new Dictionary<string, UnityEvent>();
4848

4949
void Start()
5050
{
51-
if (KeywordsAndResponses.Length > 0)
51+
int keywordCount = KeywordsAndResponses.Length;
52+
if (keywordCount > 0)
5253
{
53-
// Convert the struct array into a dictionary, with the keywords and the keys and the methods as the values.
54-
// This helps easily link the keyword recognized to the UnityEvent to be invoked.
55-
responses = KeywordsAndResponses.ToDictionary(keywordAndResponse => keywordAndResponse.Keyword,
56-
keywordAndResponse => keywordAndResponse.Response);
57-
58-
keywordRecognizer = new KeywordRecognizer(responses.Keys.ToArray());
59-
keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
60-
61-
if (RecognizerStart == RecognizerStartBehavior.AutoStart)
54+
try
6255
{
63-
keywordRecognizer.Start();
56+
string[] keywords = new string[keywordCount];
57+
// Convert the struct array into a dictionary, with the keywords and the keys and the methods as the values.
58+
// This helps easily link the keyword recognized to the UnityEvent to be invoked.
59+
for (int index = 0; index < keywordCount; index++)
60+
{
61+
KeywordAndResponse keywordAndResponse = KeywordsAndResponses[index];
62+
responses[keywordAndResponse.Keyword] = keywordAndResponse.Response;
63+
keywords[index] = keywordAndResponse.Keyword;
64+
}
65+
66+
keywordRecognizer = new KeywordRecognizer(keywords);
67+
keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
68+
69+
if (RecognizerStart == RecognizerStartBehavior.AutoStart)
70+
{
71+
keywordRecognizer.Start();
72+
}
73+
}
74+
catch (ArgumentException)
75+
{
76+
Debug.LogError("Duplicate keywords specified in the Inspector on " + gameObject.name + ".");
6477
}
6578
}
6679
else
@@ -71,7 +84,7 @@ void Start()
7184

7285
void Update()
7386
{
74-
if (keywordRecognizer.IsRunning)
87+
if (keywordRecognizer != null && keywordRecognizer.IsRunning)
7588
{
7689
ProcessKeyBindings();
7790
}
@@ -87,6 +100,22 @@ void OnDestroy()
87100
}
88101
}
89102

103+
void OnDisable()
104+
{
105+
if (keywordRecognizer != null)
106+
{
107+
StopKeywordRecognizer();
108+
}
109+
}
110+
111+
void OnEnable()
112+
{
113+
if (keywordRecognizer != null && RecognizerStart == RecognizerStartBehavior.AutoStart)
114+
{
115+
StartKeywordRecognizer();
116+
}
117+
}
118+
90119
private void ProcessKeyBindings()
91120
{
92121
foreach (var kvp in KeywordsAndResponses)

Assets/HoloToolkit/Input/Tests/Scripts/DehydrationDeactivation.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ namespace HoloToolkit.Unity.InputModule.Tests
88
public class DehydrationDeactivation : StateMachineBehaviour
99
{
1010
/// <summary>
11-
/// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
11+
/// OnStateExit is called when a transition ends and the state machine finishes evaluating this state
1212
/// </summary>
1313
/// <param name="animator">Animator that triggered OnStateEnter.</param>
1414
/// <param name="stateInfo">Animator state info.</param>
1515
/// <param name="layerIndex">Layer index.</param>
16-
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
16+
public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
1717
{
1818
animator.transform.gameObject.SetActive(false);
1919
}
2020
}
21-
}
21+
}

Assets/HoloToolkit/Utilities/Prefabs/FPSDisplay.prefab

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ GameObject:
1616
m_ObjectHideFlags: 0
1717
m_PrefabParentObject: {fileID: 0}
1818
m_PrefabInternal: {fileID: 100100000}
19-
serializedVersion: 4
19+
serializedVersion: 5
2020
m_Component:
21-
- 4: {fileID: 4000012084356042}
22-
- 23: {fileID: 23000012140561766}
23-
- 102: {fileID: 102000012390400920}
24-
- 114: {fileID: 114000014126132184}
21+
- component: {fileID: 4000012084356042}
22+
- component: {fileID: 23000012140561766}
23+
- component: {fileID: 102000012390400920}
24+
- component: {fileID: 114000014126132184}
2525
m_Layer: 0
2626
m_Name: FPSText
2727
m_TagString: Untagged
@@ -34,14 +34,14 @@ GameObject:
3434
m_ObjectHideFlags: 0
3535
m_PrefabParentObject: {fileID: 0}
3636
m_PrefabInternal: {fileID: 100100000}
37-
serializedVersion: 4
37+
serializedVersion: 5
3838
m_Component:
39-
- 4: {fileID: 4000012520274942}
40-
- 65: {fileID: 65000012561365858}
41-
- 114: {fileID: 114000013985069792}
42-
- 114: {fileID: 114000012205069828}
43-
- 114: {fileID: 114000014245746336}
44-
- 23: {fileID: 23000011797597042}
39+
- component: {fileID: 4000012520274942}
40+
- component: {fileID: 65000012561365858}
41+
- component: {fileID: 114000013985069792}
42+
- component: {fileID: 114000012205069828}
43+
- component: {fileID: 114000014245746336}
44+
- component: {fileID: 23000011797597042}
4545
m_Layer: 0
4646
m_Name: FPSDisplay
4747
m_TagString: Untagged
@@ -58,10 +58,10 @@ Transform:
5858
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
5959
m_LocalPosition: {x: 0, y: 0.11, z: 0}
6060
m_LocalScale: {x: 0.01, y: 0.01, z: 0.01}
61-
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
6261
m_Children: []
6362
m_Father: {fileID: 4000012520274942}
6463
m_RootOrder: 0
64+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
6565
--- !u!4 &4000012520274942
6666
Transform:
6767
m_ObjectHideFlags: 1
@@ -71,11 +71,11 @@ Transform:
7171
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
7272
m_LocalPosition: {x: 0, y: 0, z: 0.85}
7373
m_LocalScale: {x: 1, y: 1, z: 1}
74-
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
7574
m_Children:
7675
- {fileID: 4000012084356042}
7776
m_Father: {fileID: 0}
7877
m_RootOrder: 0
78+
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
7979
--- !u!23 &23000011797597042
8080
MeshRenderer:
8181
m_ObjectHideFlags: 1
@@ -90,15 +90,17 @@ MeshRenderer:
9090
m_ReflectionProbeUsage: 1
9191
m_Materials:
9292
- {fileID: 10100, guid: 0000000000000000e000000000000000, type: 0}
93-
m_SubsetIndices:
93+
m_StaticBatchInfo:
94+
firstSubMesh: 0
95+
subMeshCount: 0
9496
m_StaticBatchRoot: {fileID: 0}
9597
m_ProbeAnchor: {fileID: 0}
9698
m_LightProbeVolumeOverride: {fileID: 0}
9799
m_ScaleInLightmap: 1
98100
m_PreserveUVs: 0
99101
m_IgnoreNormalsForChartDetection: 0
100102
m_ImportantGI: 0
101-
m_SelectedWireframeHidden: 0
103+
m_SelectedEditorRenderState: 3
102104
m_MinimumChartSize: 4
103105
m_AutoUVMaxDistance: 0.5
104106
m_AutoUVMaxAngle: 89
@@ -119,15 +121,17 @@ MeshRenderer:
119121
m_ReflectionProbeUsage: 1
120122
m_Materials:
121123
- {fileID: 10100, guid: 0000000000000000e000000000000000, type: 0}
122-
m_SubsetIndices:
124+
m_StaticBatchInfo:
125+
firstSubMesh: 0
126+
subMeshCount: 0
123127
m_StaticBatchRoot: {fileID: 0}
124128
m_ProbeAnchor: {fileID: 0}
125129
m_LightProbeVolumeOverride: {fileID: 0}
126130
m_ScaleInLightmap: 1
127131
m_PreserveUVs: 0
128132
m_IgnoreNormalsForChartDetection: 0
129133
m_ImportantGI: 0
130-
m_SelectedWireframeHidden: 0
134+
m_SelectedEditorRenderState: 3
131135
m_MinimumChartSize: 4
132136
m_AutoUVMaxDistance: 0.5
133137
m_AutoUVMaxAngle: 89
@@ -226,4 +230,4 @@ MonoBehaviour:
226230
m_Script: {fileID: 11500000, guid: ac8d5b128a1d8204fb76c86f47b75912, type: 3}
227231
m_Name:
228232
m_EditorClassIdentifier:
229-
PivotAxis: 2
233+
PivotAxis: 1

Assets/HoloToolkit/Utilities/Scripts/FpsDisplay.cs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ public class FpsDisplay : MonoBehaviour
1515
[SerializeField]
1616
private TextMesh textMesh;
1717

18-
[Tooltip("Reference to 3DText UI control where the FPS should be displayed.")]
19-
[SerializeField]
20-
private TextMesh text3D;
21-
2218
[Tooltip("How many frames should we consider into our average calculation?")]
2319
[SerializeField]
2420
private int frameRange = 60;
@@ -59,7 +55,7 @@ private void InitBuffer()
5955
{
6056
textMesh = GetComponent<TextMesh>();
6157

62-
if(frameRange <= 0)
58+
if (frameRange <= 0)
6359
{
6460
frameRange = 1;
6561
}
@@ -76,17 +72,13 @@ private void UpdateTextDisplay(int fps)
7672
{
7773
textMesh.text = displayString;
7874
}
79-
if (text3D != null)
80-
{
81-
text3D.text = displayString;
82-
}
8375
}
8476

8577
private void UpdateFrameBuffer()
8678
{
87-
fpsBuffer[fpsBufferIndex++] = (int)(1f/Time.unscaledDeltaTime);
79+
fpsBuffer[fpsBufferIndex++] = (int)(1f / Time.unscaledDeltaTime);
8880

89-
if(fpsBufferIndex >= frameRange)
81+
if (fpsBufferIndex >= frameRange)
9082
{
9183
fpsBufferIndex = 0;
9284
}
@@ -96,7 +88,7 @@ private void CalculateFps()
9688
{
9789
int sum = 0;
9890

99-
for(int i = 0; i < frameRange; i++)
91+
for (int i = 0; i < frameRange; i++)
10092
{
10193
int fps = fpsBuffer[i];
10294
sum += fps;

0 commit comments

Comments
 (0)