Skip to content

Commit c0539d6

Browse files
Merge branch 'more-stuff' into vNEXT-CursorTest
2 parents 61c0c77 + 7c960a6 commit c0539d6

File tree

7 files changed

+91
-12
lines changed

7 files changed

+91
-12
lines changed

Assets/MixedRealityToolkit-SDK/Features/Input/GazeProvider.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
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 Microsoft.MixedReality.Toolkit.InputSystem.Pointers;
5-
using Microsoft.MixedReality.Toolkit.InputSystem.Sources;
64
using Microsoft.MixedReality.Toolkit.Core.Definitions.InputSystem;
75
using Microsoft.MixedReality.Toolkit.Core.Definitions.Utilities;
86
using Microsoft.MixedReality.Toolkit.Core.EventDatum.Input;
97
using Microsoft.MixedReality.Toolkit.Core.Interfaces.Devices;
108
using Microsoft.MixedReality.Toolkit.Core.Interfaces.InputSystem;
119
using Microsoft.MixedReality.Toolkit.Core.Interfaces.InputSystem.Handlers;
1210
using Microsoft.MixedReality.Toolkit.Core.Utilities;
11+
using Microsoft.MixedReality.Toolkit.Core.Utilities.Async;
1312
using Microsoft.MixedReality.Toolkit.Core.Utilities.Physics;
13+
using Microsoft.MixedReality.Toolkit.InputSystem.Pointers;
14+
using Microsoft.MixedReality.Toolkit.InputSystem.Sources;
1415
using UnityEngine;
1516

1617
namespace Microsoft.MixedReality.Toolkit.SDK.Input
@@ -268,8 +269,10 @@ protected override void OnEnable()
268269
}
269270
}
270271

271-
protected virtual void Start()
272+
protected override void Start()
272273
{
274+
base.Start();
275+
273276
if (cursorPrefab != null)
274277
{
275278
var cursorObj = Instantiate(cursorPrefab, transform.parent);
@@ -335,7 +338,7 @@ protected override void OnDisable()
335338
{
336339
base.OnDisable();
337340
GazePointer.BaseCursor?.SetVisibility(false);
338-
InputSystem.RaiseSourceLost(GazeInputSource);
341+
InputSystem?.RaiseSourceLost(GazeInputSource);
339342
}
340343

341344
#endregion MonoBehaviour Implementation
@@ -385,8 +388,9 @@ private IMixedRealityPointer InitializeGazePointer()
385388
return gazePointer = new InternalGazePointer(this, "Gaze Pointer", null, raycastLayerMasks, maxGazeCollisionDistance, gazeTransform, stabilizer);
386389
}
387390

388-
private void RaiseSourceDetected()
391+
private async void RaiseSourceDetected()
389392
{
393+
await WaitUntilInputSystemValid;
390394
InputSystem.RaiseSourceDetected(GazeInputSource);
391395
GazePointer.BaseCursor?.SetVisibility(true);
392396
}

Assets/MixedRealityToolkit-SDK/Features/Input/Handlers/SpeechInputHandler.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ public class SpeechInputHandler : BaseInputHandler, IMixedRealitySpeechHandler
3333

3434
#region MonoBehaviour Implementation
3535

36-
private void Start()
36+
protected override void Start()
3737
{
38+
base.Start();
39+
3840
if (persistentKeywords)
3941
{
4042
Debug.Assert(gameObject.transform.parent == null, "Persistent keyword GameObject must be at the root level of the scene hierarchy.");

Assets/MixedRealityToolkit-SDK/Features/Input/InputSystemGlobalListener.cs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using Microsoft.MixedReality.Toolkit.Core.Interfaces.InputSystem;
55
using Microsoft.MixedReality.Toolkit.Core.Managers;
6+
using Microsoft.MixedReality.Toolkit.Core.Utilities.Async;
67
using UnityEngine;
78

89
namespace Microsoft.MixedReality.Toolkit.SDK.Input
@@ -15,16 +16,31 @@ public class InputSystemGlobalListener : MonoBehaviour
1516
private static IMixedRealityInputSystem inputSystem = null;
1617
protected static IMixedRealityInputSystem InputSystem => inputSystem ?? (inputSystem = MixedRealityManager.Instance.GetManager<IMixedRealityInputSystem>());
1718

19+
private bool lateInitialize = true;
20+
21+
protected readonly WaitUntil WaitUntilInputSystemValid = new WaitUntil(() => InputSystem != null);
22+
1823
protected virtual void OnEnable()
1924
{
20-
Debug.Assert(MixedRealityManager.IsInitialized, "No Mixed Reality Manager found in the scene. Be sure to run the Mixed Reality Configuration.");
21-
Debug.Assert(InputSystem != null, "No Input System found, Did you set it up in your configuration profile?");
22-
InputSystem.Register(gameObject);
25+
if (MixedRealityManager.IsInitialized && InputSystem != null && !lateInitialize)
26+
{
27+
InputSystem.Register(gameObject);
28+
}
29+
}
30+
31+
protected virtual async void Start()
32+
{
33+
if (lateInitialize)
34+
{
35+
await WaitUntilInputSystemValid;
36+
lateInitialize = false;
37+
InputSystem.Register(gameObject);
38+
}
2339
}
2440

2541
protected virtual void OnDisable()
2642
{
27-
InputSystem.Unregister(gameObject);
43+
InputSystem?.Unregister(gameObject);
2844
}
2945
}
3046
}

Assets/MixedRealityToolkit-SDK/Features/UX/Scripts/Cursors/BaseCursor.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,10 @@ protected virtual void UpdateCursorTransform()
316316
{
317317
Debug.LogError($"{name}: Unable to get focus details for {pointer.GetType().Name}!");
318318
}
319+
else if (pointer.GetType() != typeof(TouchPointer))
320+
{
321+
Debug.LogWarning($"{pointer.GetType().Name} not registered!");
322+
}
319323

320324
return;
321325
}

Assets/MixedRealityToolkit-SDK/Features/UX/Scripts/Pointers/BaseControllerPointer.cs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ public abstract class BaseControllerPointer : ControllerPoseSynchronizer, IMixed
6161

6262
protected bool IsTeleportRequestActive = false;
6363

64+
private bool lateRegisterTeleport = false;
65+
6466
/// <summary>
6567
/// The forward direction of the targeting ray
6668
/// </summary>
@@ -116,7 +118,33 @@ protected override void OnEnable()
116118
base.OnEnable();
117119
SetCursor();
118120
BaseCursor?.SetVisibility(true);
119-
TeleportSystem?.Register(gameObject);
121+
122+
if (TeleportSystem == null)
123+
{
124+
lateRegisterTeleport = true;
125+
}
126+
else if (!lateRegisterTeleport)
127+
{
128+
TeleportSystem.Register(gameObject);
129+
}
130+
}
131+
132+
protected override void Start()
133+
{
134+
base.Start();
135+
136+
if (lateRegisterTeleport)
137+
{
138+
if (TeleportSystem == null)
139+
{
140+
Debug.LogError("Failed to find the Teleport System!");
141+
}
142+
else
143+
{
144+
lateRegisterTeleport = false;
145+
TeleportSystem.Register(gameObject);
146+
}
147+
}
120148
}
121149

122150
protected override void OnDisable()

Assets/MixedRealityToolkit/_Core/Definitions/MixedRealityComponentConfiguration.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,31 @@ namespace Microsoft.MixedReality.Toolkit.Core.Definitions
1515
[Serializable]
1616
public struct MixedRealityComponentConfiguration
1717
{
18+
/// <summary>
19+
/// Constructor.
20+
/// </summary>
21+
/// <param name="componentType">The concrete type for the system, feature or manager.</param>
22+
/// <param name="componentName">The simple, human readable name for the system, feature, or manager.</param>
23+
/// <param name="priority">The priority this system, feature, or manager will be initialized in.</param>
24+
/// <param name="runtimePlatform">The runtime platform(s) to run this system, feature, or manager on.</param>
25+
/// <param name="configurationProfile">The configuration profile for the system, feature, or manager.</param>
26+
/// <param name="editorPlatform">The editor platform(s) to run this system, feature, or manager on.</param>
27+
public MixedRealityComponentConfiguration(SystemType componentType, string componentName, uint priority, RuntimePlatform runtimePlatform, ScriptableObject configurationProfile
28+
#if UNITY_EDITOR
29+
, UnityEditor.BuildTarget editorPlatform
30+
#endif
31+
)
32+
{
33+
this.componentType = componentType;
34+
this.componentName = componentName;
35+
this.priority = priority;
36+
this.runtimePlatform = runtimePlatform;
37+
this.configurationProfile = configurationProfile;
38+
#if UNITY_EDITOR
39+
this.editorPlatform = editorPlatform;
40+
#endif
41+
}
42+
1843
[SerializeField]
1944
[Implements(typeof(IMixedRealityComponent), TypeGrouping.ByNamespaceFlat)]
2045
private SystemType componentType;

Assets/MixedRealityToolkit/_Core/Definitions/MixedRealityConfigurationProfile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ public float TeleportDuration
216216

217217
[SerializeField]
218218
[Tooltip("All the additional non-required systems, features, and managers registered with the Mixed Reality Manager.")]
219-
private MixedRealityRegisteredComponentsProfile registeredComponentsProfile;
219+
private MixedRealityRegisteredComponentsProfile registeredComponentsProfile = null;
220220

221221
/// <summary>
222222
/// All the additional non-required systems, features, and managers registered with the Mixed Reality Manager.

0 commit comments

Comments
 (0)