Skip to content

Commit 9332d1b

Browse files
authored
Merge pull request #9329 from microsoft/prerelease/2.6.0_stabilization
Branch synchronization: prerelease/2.6.0_stabilization --> mrtk_development
2 parents 86fa40b + 3e3a980 commit 9332d1b

File tree

39 files changed

+212
-92
lines changed

39 files changed

+212
-92
lines changed

Assets/MRTK/Core/MRTK.Core.asmdef

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,19 @@
44
"Microsoft.MixedReality.Toolkit.Async",
55
"Microsoft.MixedReality.Toolkit.Editor.Utilities"
66
],
7-
"optionalUnityReferences": [],
87
"includePlatforms": [],
98
"excludePlatforms": [],
109
"allowUnsafeCode": false,
1110
"overrideReferences": false,
1211
"precompiledReferences": [],
1312
"autoReferenced": true,
14-
"defineConstraints": []
13+
"defineConstraints": [],
14+
"versionDefines": [
15+
{
16+
"name": "com.microsoft.windows.mixedreality.dotnetwinrt",
17+
"expression": "",
18+
"define": "DOTNETWINRT_PRESENT"
19+
}
20+
],
21+
"noEngineReferences": false
1522
}

Assets/MRTK/Core/Services/BaseService.cs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,49 +66,46 @@ public virtual void Destroy()
6666

6767
#region IMixedRealityServiceState Implementation
6868

69-
protected bool? isInitialized = null;
69+
private bool? isInitialized = null;
7070

7171
/// <inheritdoc />
7272
public virtual bool IsInitialized
7373
{
7474
get
7575
{
76-
Debug.Assert(isInitialized.HasValue, $"{this.GetType()} has not set a value for IsInitialized, returning false.");
76+
Debug.Assert(isInitialized.HasValue, $"{GetType()} has not set a value for IsInitialized, returning false.");
7777
return isInitialized ?? false;
7878
}
7979

80-
set => isInitialized = value;
80+
protected set => isInitialized = value;
8181
}
8282

83-
protected bool? isEnabled = null;
83+
private bool? isEnabled = null;
8484

8585
/// <inheritdoc />
8686
public virtual bool IsEnabled
8787
{
8888
get
8989
{
90-
Debug.Assert(isEnabled.HasValue, $"{this.GetType()} has not set a value for IsEnabled, returning false.");
90+
Debug.Assert(isEnabled.HasValue, $"{GetType()} has not set a value for IsEnabled, returning false.");
9191
return isEnabled ?? false;
9292
}
9393

94-
set => isEnabled = value;
94+
protected set => isEnabled = value;
9595
}
9696

97-
/// <summary>
98-
///
99-
/// </summary>
100-
protected bool? isMarkedDestroyed = null;
97+
private bool? isMarkedDestroyed = null;
10198

10299
/// <inheritdoc />
103100
public virtual bool IsMarkedDestroyed
104101
{
105102
get
106103
{
107-
Debug.Assert(isMarkedDestroyed.HasValue, $"{this.GetType()} has not set a value for IsMarkedDestroyed, returning false.");
104+
Debug.Assert(isMarkedDestroyed.HasValue, $"{GetType()} has not set a value for IsMarkedDestroyed, returning false.");
108105
return isMarkedDestroyed ?? false;
109106
}
110107

111-
set => isMarkedDestroyed = value;
108+
protected set => isMarkedDestroyed = value;
112109
}
113110

114111
#endregion IMixedRealityServiceState Implementation

Assets/MRTK/Extensions/HandPhysicsService/HandPhysicsService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace Microsoft.MixedReality.Toolkit.Extensions.HandPhysics
1313
/// A simple service that creates KinematicRigidbodies on fingertips for physics interactions.
1414
/// </summary>
1515
[MixedRealityExtensionService(
16-
SupportedPlatforms.WindowsUniversal,
16+
(SupportedPlatforms)(-1),
1717
"Hand Physics Service",
1818
"HandPhysicsService/Profiles/DefaultHandPhysicsServiceProfile.asset",
1919
"MixedRealityToolkit.Extensions",

Assets/MRTK/Extensions/HandPhysicsService/MRTK.HandPhysics.asmdef

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,12 @@
44
"Microsoft.MixedReality.Toolkit",
55
"Unity.TextMeshPro"
66
],
7-
"includePlatforms": [
8-
"Android",
9-
"Editor",
10-
"WSA"
11-
],
7+
"optionalUnityReferences": [],
8+
"includePlatforms": [],
129
"excludePlatforms": [],
1310
"allowUnsafeCode": false,
1411
"overrideReferences": false,
1512
"precompiledReferences": [],
1613
"autoReferenced": true,
17-
"defineConstraints": [],
18-
"versionDefines": [],
19-
"noEngineReferences": false
14+
"defineConstraints": []
2015
}

Assets/MRTK/Extensions/HandPhysicsService/Profiles/HandPhysicsMixedRealityRegisteredServiceProvidersProfile.asset

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ MonoBehaviour:
1919
Microsoft.MixedReality.Toolkit.Extensions.HandPhysics
2020
componentName: HandPhysicsService
2121
priority: 10
22-
runtimePlatform: 1272
22+
runtimePlatform: -1
2323
configurationProfile: {fileID: 11400000, guid: 236baf35803f73342b69c842fe4afb1c,
2424
type: 2}

Assets/MRTK/Providers/Oculus/XRSDK/MRTK.Oculus.asmdef

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"Microsoft.MixedReality.Toolkit.Services.InputSystem",
66
"Microsoft.MixedReality.Toolkit.SDK",
77
"Microsoft.MixedReality.Toolkit.Providers.XRSDK",
8+
"Unity.XR.Management",
89
"Unity.XR.Oculus",
910
"Oculus.VR"
1011
],

Assets/MRTK/Providers/Oculus/XRSDK/OculusXRSDKDeviceManager.cs

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,16 @@
55
using Microsoft.MixedReality.Toolkit.Utilities;
66
using Microsoft.MixedReality.Toolkit.XRSDK.Input;
77
using System;
8+
using UnityEngine.XR;
9+
10+
#if OCULUS_ENABLED
11+
using Unity.XR.Oculus;
12+
#endif // OCULUS_ENABLED
13+
14+
#if OCULUSINTEGRATION_PRESENT
815
using System.Collections.Generic;
916
using UnityEngine;
10-
using UnityEngine.XR;
17+
#endif // OCULUSINTEGRATION_PRESENT
1118

1219
namespace Microsoft.MixedReality.Toolkit.XRSDK.Oculus.Input
1320
{
@@ -39,25 +46,22 @@ public OculusXRSDKDeviceManager(
3946
public override void Initialize()
4047
{
4148
base.Initialize();
42-
Debug.Log(@"Detected a potential deployment issue for the Oculus Quest. In order to use handtracking with the Oculus Quest, download the Oculus Integration Package from the Unity Asset Store and run the Integration tool before deploying.
49+
Debug.Log(@"Detected a potential deployment issue for the Oculus Quest. In order to use hand tracking with the Oculus Quest, download the Oculus Integration Package from the Unity Asset Store and run the Integration tool before deploying.
4350
The tool can be found under <i>Mixed Reality Toolkit > Utilities > Oculus > Integrate Oculus Integration Unity Modules</i>");
4451
}
4552
#endif
4653

47-
private Dictionary<Handedness, OculusHand> trackedHands = new Dictionary<Handedness, OculusHand>();
48-
4954
#if OCULUSINTEGRATION_PRESENT
55+
private readonly Dictionary<Handedness, OculusHand> trackedHands = new Dictionary<Handedness, OculusHand>();
56+
5057
private OVRCameraRig cameraRig;
5158

5259
private OVRHand rightHand;
53-
private OVRMeshRenderer rightMeshRenderer;
5460
private OVRSkeleton rightSkeleton;
5561

5662
private OVRHand leftHand;
57-
private OVRMeshRenderer leftMeshRenderer;
5863
private OVRSkeleton leftSkeleton;
5964

60-
6165
/// <summary>
6266
/// The profile that contains settings for the Oculus XRSDK Device Manager input data provider. This profile is nested under
6367
/// Input > Input Data Providers > Oculus XRSDK Device Manager in the MixedRealityToolkit object in the hierarchy.
@@ -80,8 +84,9 @@ public override bool CheckCapability(MixedRealityCapability capability)
8084
}
8185

8286
#endregion IMixedRealityCapabilityCheck Implementation
83-
87+
8488
#region Controller Utilities
89+
8590
/// <inheritdoc />
8691
protected override Type GetControllerType(SupportedControllerType supportedControllerType)
8792
{
@@ -133,22 +138,50 @@ protected override SupportedControllerType GetCurrentControllerType(InputDevice
133138

134139
#endregion Controller Utilities
135140

141+
private bool? isActiveLoader = null;
142+
private bool IsActiveLoader
143+
{
144+
get
145+
{
146+
#if OCULUS_ENABLED
147+
if (!isActiveLoader.HasValue)
148+
{
149+
isActiveLoader = IsLoaderActive<OculusLoader>();
150+
}
151+
#endif // OCULUS_ENABLED
152+
153+
return isActiveLoader ?? false;
154+
}
155+
}
136156

137-
#if OCULUSINTEGRATION_PRESENT
138157
/// <inheritdoc/>
139158
public override void Enable()
140159
{
160+
if (!IsActiveLoader)
161+
{
162+
IsEnabled = false;
163+
return;
164+
}
165+
141166
base.Enable();
142167

168+
#if OCULUSINTEGRATION_PRESENT
143169
SetupInput();
144170
ConfigurePerformancePreferences();
171+
#endif // OCULUSINTEGRATION_PRESENT
145172
}
146173

147-
174+
#if OCULUSINTEGRATION_PRESENT
148175
/// <inheritdoc/>
149176
public override void Update()
150177
{
178+
if (!IsEnabled)
179+
{
180+
return;
181+
}
182+
151183
base.Update();
184+
152185
if (OVRPlugin.GetHandTrackingEnabled())
153186
{
154187
UpdateHands();
@@ -193,7 +226,7 @@ private void SetupInput()
193226
}
194227

195228
bool useAvatarHands = SettingsProfile.RenderAvatarHandsInsteadOfController;
196-
// If using Avatar hands, de-activate ovr controller rendering
229+
// If using Avatar hands, deactivate ovr controller rendering
197230
foreach (var controllerHelper in cameraRig.gameObject.GetComponentsInChildren<OVRControllerHelper>())
198231
{
199232
controllerHelper.gameObject.SetActive(!useAvatarHands);
@@ -239,6 +272,7 @@ private void ConfigurePerformancePreferences()
239272
}
240273

241274
#region Hand Utilities
275+
242276
protected void UpdateHands()
243277
{
244278
UpdateHand(rightHand, rightSkeleton, Handedness.Right);
@@ -269,8 +303,7 @@ private OculusHand GetOrAddHand(Handedness handedness, OVRHand ovrHand)
269303
var pointers = RequestPointers(SupportedControllerType.ArticulatedHand, handedness);
270304
var inputSourceType = InputSourceType.Hand;
271305

272-
IMixedRealityInputSystem inputSystem = Service as IMixedRealityInputSystem;
273-
var inputSource = inputSystem?.RequestNewGenericInputSource($"Oculus Quest {handedness} Hand", pointers, inputSourceType);
306+
var inputSource = Service?.RequestNewGenericInputSource($"Oculus Quest {handedness} Hand", pointers, inputSourceType);
274307

275308

276309
OculusHand handDevice = new OculusHand(TrackingState.Tracked, handedness, inputSource);
@@ -281,7 +314,7 @@ private OculusHand GetOrAddHand(Handedness handedness, OVRHand ovrHand)
281314
handDevice.InputSource.Pointers[i].Controller = handDevice;
282315
}
283316

284-
inputSystem?.RaiseSourceDetected(handDevice.InputSource, handDevice);
317+
Service?.RaiseSourceDetected(handDevice.InputSource, handDevice);
285318

286319
trackedHands.Add(handedness, handDevice);
287320

@@ -317,8 +350,8 @@ private void RemoveHandDevice(OculusHand handDevice)
317350

318351
RecyclePointers(handDevice.InputSource);
319352
}
353+
320354
#endregion
321-
322-
#endif
355+
#endif // OCULUSINTEGRATION_PRESENT
323356
}
324357
}

Assets/MRTK/Providers/OpenXR/MRTK.OpenXR.asmdef

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"Microsoft.MixedReality.OpenXR",
66
"Microsoft.MixedReality.Toolkit",
77
"Microsoft.MixedReality.Toolkit.Providers.XRSDK",
8+
"Unity.XR.Management",
89
"Unity.XR.OpenXR"
910
],
1011
"includePlatforms": [

Assets/MRTK/Providers/OpenXR/Scripts/OpenXRDeviceManager.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
using Unity.Profiling;
99
using UnityEngine.XR;
1010

11+
#if UNITY_OPENXR
12+
using UnityEngine.XR.OpenXR;
13+
#endif // UNITY_OPENXR
14+
1115
namespace Microsoft.MixedReality.Toolkit.XRSDK.OpenXR
1216
{
1317
[MixedRealityDataProvider(
@@ -29,6 +33,34 @@ public OpenXRDeviceManager(
2933
uint priority = DefaultPriority,
3034
BaseMixedRealityProfile profile = null) : base(inputSystem, name, priority, profile) { }
3135

36+
private bool? isActiveLoader = null;
37+
private bool IsActiveLoader
38+
{
39+
get
40+
{
41+
#if UNITY_OPENXR
42+
if (!isActiveLoader.HasValue)
43+
{
44+
isActiveLoader = IsLoaderActive<OpenXRLoader>();
45+
}
46+
#endif // UNITY_OPENXR
47+
48+
return isActiveLoader ?? false;
49+
}
50+
}
51+
52+
/// <inheritdoc />
53+
public override void Enable()
54+
{
55+
if (!IsActiveLoader)
56+
{
57+
IsEnabled = false;
58+
return;
59+
}
60+
61+
base.Enable();
62+
}
63+
3264
#region Controller Utilities
3365

3466
private static readonly ProfilerMarker GetOrAddControllerPerfMarker = new ProfilerMarker("[MRTK] OpenXRDeviceManager.GetOrAddController");

Assets/MRTK/Providers/WindowsMixedReality/Shared/MRTK.WMR.Shared.asmdef

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
"name": "com.microsoft.mixedreality.input",
2121
"expression": "",
2222
"define": "HP_CONTROLLER_ENABLED"
23+
},
24+
{
25+
"name": "com.microsoft.windows.mixedreality.dotnetwinrt",
26+
"expression": "",
27+
"define": "DOTNETWINRT_PRESENT"
2328
}
2429
],
2530
"noEngineReferences": false

0 commit comments

Comments
 (0)