Skip to content

Commit 083ba1e

Browse files
fixed cross platform support from last refactor PR
1 parent 500522b commit 083ba1e

File tree

5 files changed

+29
-24
lines changed

5 files changed

+29
-24
lines changed

Assets/HoloToolkit/Input/Scripts/HandGuidance.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
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 UnityEngine;
54

65
#if UNITY_WSA
6+
using UnityEngine;
77
using UnityEngine.VR.WSA.Input;
88
#endif
99

@@ -14,6 +14,7 @@ namespace HoloToolkit.Unity.InputModule
1414
/// </summary>
1515
public class HandGuidance : Singleton<HandGuidance>
1616
{
17+
#if UNITY_WSA
1718
[Tooltip("The Cursor object the HandGuidanceIndicator will be positioned around.")]
1819
public GameObject Cursor;
1920

@@ -31,7 +32,6 @@ public class HandGuidance : Singleton<HandGuidance>
3132

3233
private uint? currentlyTrackedHand = null;
3334

34-
#if UNITY_WSA
3535
protected override void Awake()
3636
{
3737
base.Awake();

Assets/HoloToolkit/Input/Scripts/InputManager.cs

+17-12
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ public class InputManager : Singleton<InputManager>
4545
private ManipulationEventData manipulationEventData;
4646
private HoldEventData holdEventData;
4747
private NavigationEventData navigationEventData;
48+
49+
#if UNITY_WSA || UNITY_STANDALONE_WIN
4850
private SpeechKeywordRecognizedEventData speechKeywordRecognizedEventData;
4951
private DictationEventData dictationEventData;
52+
#endif
5053

5154
/// <summary>
5255
/// Indicates if input is currently enabled or not.
@@ -184,11 +187,13 @@ private void InitializeEventDatas()
184187
manipulationEventData = new ManipulationEventData(EventSystem.current);
185188
navigationEventData = new NavigationEventData(EventSystem.current);
186189
holdEventData = new HoldEventData(EventSystem.current);
190+
#if UNITY_WSA || UNITY_STANDALONE_WIN
187191
speechKeywordRecognizedEventData = new SpeechKeywordRecognizedEventData(EventSystem.current);
188192
dictationEventData = new DictationEventData(EventSystem.current);
193+
#endif
189194
}
190195

191-
#region Unity Methods
196+
#region Unity Methods
192197

193198
private void Start()
194199
{
@@ -217,7 +222,7 @@ protected override void OnDestroy()
217222
UnregisterGazeManager();
218223
}
219224

220-
#endregion // Unity Methods
225+
#endregion // Unity Methods
221226

222227
public void HandleEvent<T>(BaseEventData eventData, ExecuteEvents.EventFunction<T> eventHandler)
223228
where T : IEventSystemHandler
@@ -450,7 +455,7 @@ public void RaiseSourceLost(IInputSource source, uint sourceId)
450455
HandleEvent(sourceStateEventData, OnSourceLostEventHandler);
451456
}
452457

453-
#region Manipulation Events
458+
#region Manipulation Events
454459

455460
private static readonly ExecuteEvents.EventFunction<IManipulationHandler> OnManipulationStartedEventHandler =
456461
delegate (IManipulationHandler handler, BaseEventData eventData)
@@ -516,9 +521,9 @@ public void RaiseManipulationCanceled(IInputSource source, uint sourceId, Vector
516521
HandleEvent(manipulationEventData, OnManipulationCanceledEventHandler);
517522
}
518523

519-
#endregion // Manipulation Events
524+
#endregion // Manipulation Events
520525

521-
#region Hold Events
526+
#region Hold Events
522527

523528
private static readonly ExecuteEvents.EventFunction<IHoldHandler> OnHoldStartedEventHandler =
524529
delegate (IHoldHandler handler, BaseEventData eventData)
@@ -568,9 +573,9 @@ public void RaiseHoldCanceled(IInputSource source, uint sourceId)
568573
HandleEvent(holdEventData, OnHoldCanceledEventHandler);
569574
}
570575

571-
#endregion // Hold Events
576+
#endregion // Hold Events
572577

573-
#region Navigation Events
578+
#region Navigation Events
574579

575580
private static readonly ExecuteEvents.EventFunction<INavigationHandler> OnNavigationStartedEventHandler =
576581
delegate (INavigationHandler handler, BaseEventData eventData)
@@ -636,10 +641,10 @@ public void RaiseNavigationCanceled(IInputSource source, uint sourceId, Vector3
636641
HandleEvent(navigationEventData, OnNavigationCanceledEventHandler);
637642
}
638643

639-
#endregion // Navigation Events
644+
#endregion // Navigation Events
640645

641646
#if UNITY_WSA || UNITY_STANDALONE_WIN
642-
#region Speech Events
647+
#region Speech Events
643648

644649
private static readonly ExecuteEvents.EventFunction<ISpeechHandler> OnSpeechKeywordRecognizedEventHandler =
645650
delegate (ISpeechHandler handler, BaseEventData eventData)
@@ -664,9 +669,9 @@ public void RaiseSpeechKeywordPhraseRecognized(IInputSource source, uint sourceI
664669
handler.OnDictationHypothesis(casted);
665670
};
666671

667-
#endregion // Speech Events
672+
#endregion // Speech Events
668673

669-
#region Dictation Events
674+
#region Dictation Events
670675

671676
public void RaiseDictationHypothesis(IInputSource source, uint sourceId, string dictationHypothesis, AudioClip dictationAudioClip = null)
672677
{
@@ -725,7 +730,7 @@ public void RaiseDictationError(IInputSource source, uint sourceId, string dicta
725730
HandleEvent(dictationEventData, OnDictationErrorEventHandler);
726731
}
727732

728-
#endregion // Dictation Events
733+
#endregion // Dictation Events
729734
#endif
730735
}
731736
}

Assets/HoloToolkit/Input/Scripts/Microphone/DictationInputManager.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

44
using System.Collections;
5-
using System.Text;
65
using UnityEngine;
76

87
#if UNITY_WSA || UNITY_STANDALONE_WIN
8+
using System.Text;
99
using UnityEngine.Windows.Speech;
1010
#endif
1111

@@ -17,6 +17,7 @@ namespace HoloToolkit.Unity.InputModule
1717
/// </summary>
1818
public class DictationInputManager : Singleton<DictationInputManager>, IInputSource
1919
{
20+
#if UNITY_WSA || UNITY_STANDALONE_WIN
2021
/// <summary>
2122
/// Caches the text currently being displayed in dictation display text.
2223
/// </summary>
@@ -47,12 +48,12 @@ public class DictationInputManager : Singleton<DictationInputManager>, IInputSou
4748
/// Audio clip of the last dictation session.
4849
/// </summary>
4950
private static AudioClip dictationAudioClip;
50-
#if UNITY_WSA || UNITY_STANDALONE_WIN
51+
5152
private static DictationRecognizer dictationRecognizer;
52-
#endif
53+
5354
private static bool isTransitioning;
54-
5555
private static bool hasFailed;
56+
#endif
5657

5758
#region Unity Methods
5859

@@ -187,6 +188,7 @@ public static IEnumerator StopRecording()
187188
}
188189

189190
#region Dictation Recognizer Callbacks
191+
#if UNITY_WSA || UNITY_STANDALONE_WIN
190192

191193
/// <summary>
192194
/// This event is fired while the user is talking. As the recognizer listens, it provides text of what it's heard so far.
@@ -200,7 +202,6 @@ private static void DictationRecognizer_DictationHypothesis(string text)
200202
InputManager.Instance.RaiseDictationHypothesis(Instance, 0, dictationResult);
201203
}
202204

203-
#if UNITY_WSA || UNITY_STANDALONE_WIN
204205
/// <summary>
205206
/// This event is fired after the user pauses, typically at the end of a sentence. The full recognized string is returned here.
206207
/// </summary>
@@ -234,7 +235,6 @@ private static void DictationRecognizer_DictationComplete(DictationCompletionCau
234235
textSoFar = null;
235236
dictationResult = string.Empty;
236237
}
237-
#endif
238238

239239
/// <summary>
240240
/// This event is fired when an error occurs.
@@ -249,7 +249,7 @@ private static void DictationRecognizer_DictationError(string error, int hresult
249249
textSoFar = null;
250250
dictationResult = string.Empty;
251251
}
252-
252+
#endif
253253
#endregion // Dictation Recognizer Callbacks
254254

255255
#region IInputSource Implementation

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public enum RecognizerStartBehavior { AutoStart, ManualStart };
4747
[Tooltip("An array of string keywords and UnityEvents, to be set in the Inspector.")]
4848
public KeywordAndResponse[] KeywordsAndResponses;
4949

50-
private readonly Dictionary<string, UnityEvent> responses = new Dictionary<string, UnityEvent>();
5150
#if UNITY_WSA || UNITY_STANDALONE_WIN
51+
private readonly Dictionary<string, UnityEvent> responses = new Dictionary<string, UnityEvent>();
5252
private KeywordRecognizer keywordRecognizer;
5353

5454
void Start()

Assets/HoloToolkit/SpatialMapping/Scripts/RemoteMapping/RemoteMappingManager.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,20 @@ public partial class RemoteMappingManager : Singleton<RemoteMappingManager>
3232
/// Used for voice commands.
3333
/// </summary>
3434
private KeywordRecognizer keywordRecognizer;
35-
#endif
3635

3736
/// <summary>
3837
/// Collection of supported keywords and their associated actions.
3938
/// </summary>
4039
private Dictionary<string, System.Action> keywordCollection;
40+
#endif
4141

4242
// Use this for initialization.
4343
private void Start()
4444
{
45+
#if UNITY_WSA || UNITY_STANDALONE_WIN
4546
// Create our keyword collection.
4647
keywordCollection = new Dictionary<string, System.Action> { { SendMeshesKeyword, SendMeshes } };
4748

48-
#if UNITY_WSA || UNITY_STANDALONE_WIN
4949
// Tell the KeywordRecognizer about our keywords.
5050
keywordRecognizer = new KeywordRecognizer(keywordCollection.Keys.ToArray());
5151
// Register a callback for the KeywordRecognizer and start recognizing.

0 commit comments

Comments
 (0)