Skip to content

Commit 6a3b50e

Browse files
author
David Kline
authored
Merge pull request #3501 from Microsoft/beta2-stabilization
Beta2 stabilization -> mrtk development
2 parents c94225d + 26ad786 commit 6a3b50e

18 files changed

+153
-55
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0"?>
2+
<package >
3+
<metadata>
4+
<id>Microsoft.MixedReality.Toolkit.Providers</id>
5+
<version>$version$</version>
6+
<authors>Microsoft</authors>
7+
<owners>Microsoft,MixedReality</owners>
8+
<licenseUrl>https://github.com/Microsoft/MixedRealityToolkit-Unity/blob/master/License.txt</licenseUrl>
9+
<projectUrl>https://github.com/Microsoft/MixedRealityToolkit-Unity</projectUrl>
10+
<requireLicenseAcceptance>true</requireLicenseAcceptance>
11+
<description>The Mixed Reality Toolkit is a collection of scripts and components intended to accelerate development of applications targeting Microsoft HoloLens and Windows Mixed Reality headsets.</description>
12+
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
13+
<releaseNotes>$releaseNotes$</releaseNotes>
14+
<tags>Unity MixedReality</tags>
15+
</metadata>
16+
</package>

Assets/MixedRealityToolkit.Providers/MixedReality.Toolkit.Providers.nuspec.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/MixedRealityToolkit.Providers/OpenVR/OpenVRDeviceManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ protected override GenericJoystickController GetOrAddController(string joystickN
9696

9797
if (!detectedController.SetupConfiguration(controllerType))
9898
{
99-
// Controller failed to be setup correctly.
100-
Debug.LogError($"Failed to Setup {controllerType.Name} controller");
99+
// Controller failed to be set up correctly.
100+
Debug.LogError($"Failed to set up {controllerType.Name} controller");
101101
// Return null so we don't raise the source detected.
102102
return null;
103103
}

Assets/MixedRealityToolkit.Providers/WindowsMixedReality/WindowsMixedRealityController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ private void UpdateTriggerData(InteractionSourceState interactionSourceState, Mi
394394
switch (interactionMapping.InputType)
395395
{
396396
case DeviceInputType.TriggerPress:
397-
//Update the interaction data source
397+
// Update the interaction data source
398398
interactionMapping.BoolData = interactionSourceState.grasped;
399399

400400
// If our value changed raise it.

Assets/MixedRealityToolkit.Providers/WindowsMixedReality/WindowsMixedRealityDeviceManager.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ public override IMixedRealityController[] GetActiveControllers()
5959
return activeControllers.Values.ToArray();
6060
}
6161

62+
#region Gesture Settings
63+
6264
private static bool gestureRecognizerEnabled;
6365

6466
/// <summary>
@@ -222,6 +224,8 @@ public static bool UseRailsNavigation
222224
private static WsaGestureSettings WSANavigationSettings => (WsaGestureSettings)navigationSettings;
223225
private static WsaGestureSettings WSARailsNavigationSettings => (WsaGestureSettings)railsNavigationSettings;
224226

227+
#endregion Gesture Settings
228+
225229
#region IMixedRealityDeviceManager Interface
226230

227231
/// <inheritdoc/>
@@ -294,7 +298,9 @@ public override void Update()
294298

295299
for (var i = 0; i < interactionmanagerStates?.Length; i++)
296300
{
297-
var controller = GetController(interactionmanagerStates[i].source);
301+
// SourceDetected gets raised when a new controller is detected and, if previously present,
302+
// when OnEnable is called. Do not create a new controller here.
303+
var controller = GetController(interactionmanagerStates[i].source, false);
298304

299305
if (controller != null)
300306
{
@@ -373,7 +379,7 @@ public override void Disable()
373379
InteractionSourceState[] states = InteractionManager.GetCurrentReading();
374380
for (var i = 0; i < states.Length; i++)
375381
{
376-
RemoveController(states[i]);
382+
RemoveController(states[i].source);
377383
}
378384
}
379385

@@ -438,16 +444,16 @@ private WindowsMixedRealityController GetController(InteractionSource interactio
438444
/// Remove the selected controller from the Active Store
439445
/// </summary>
440446
/// <param name="interactionSourceState">Source State provided by the SDK to remove</param>
441-
private void RemoveController(InteractionSourceState interactionSourceState)
447+
private void RemoveController(InteractionSource interactionSource)
442448
{
443-
var controller = GetController(interactionSourceState.source, false);
449+
var controller = GetController(interactionSource, false);
444450

445451
if (controller != null)
446452
{
447453
MixedRealityToolkit.InputSystem?.RaiseSourceLost(controller.InputSource, controller);
448454
}
449455

450-
activeControllers.Remove(interactionSourceState.source.id);
456+
activeControllers.Remove(interactionSource.id);
451457
}
452458

453459
#endregion Controller Utilities
@@ -478,7 +484,7 @@ private void InteractionManager_InteractionSourceDetected(InteractionSourceDetec
478484
/// <param name="args">SDK source updated event arguments</param>
479485
private void InteractionManager_InteractionSourceLost(InteractionSourceLostEventArgs args)
480486
{
481-
RemoveController(args.state);
487+
RemoveController(args.state.source);
482488
}
483489

484490
#endregion Unity InteractionManager Events

Assets/MixedRealityToolkit.Providers/WindowsMixedReality/WindowsMixedRealitySpatialMeshObserver.cs

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,26 +69,24 @@ private void ReadProfile()
6969

7070
#region IMixedRealityToolkit implementation
7171

72+
#if UNITY_WSA
73+
7274
/// <inheritdoc />
7375
public override void Initialize()
7476
{
7577
// Only initialize if the Spatial Awareness system has been enabled in the configuration profile.
7678
if (!MixedRealityToolkit.Instance.ActiveProfile.IsSpatialAwarenessSystemEnabled) { return; }
7779

78-
#if UNITY_WSA
7980
CreateObserver();
8081

8182
// Apply the initial observer volume settings.
8283
ConfigureObserverVolume();
83-
#endif // UNITY_WSA
8484
}
8585

8686
/// <inheritdoc />
8787
public override void Reset()
8888
{
89-
#if UNITY_WSA
9089
CleanupObserver();
91-
#endif // UNITY_WSA
9290
Initialize();
9391
}
9492

@@ -101,9 +99,7 @@ public override void Enable()
10199
/// <inheritdoc />
102100
public override void Update()
103101
{
104-
#if UNITY_WSA
105102
UpdateObserver();
106-
#endif // UNITY_WSA
107103
}
108104

109105
/// <inheritdoc />
@@ -115,11 +111,11 @@ public override void Disable()
115111
/// <inheritdoc />
116112
public override void Destroy()
117113
{
118-
#if UNITY_WSA
119114
CleanupObserver();
120-
#endif // UNITY_WSA
121115
}
122116

117+
#endif // UNITY_WSA
118+
123119
#endregion IMixedRealityToolkit implementation
124120

125121
#region IMixedRealitySpatialAwarenessObserver implementation
@@ -140,6 +136,28 @@ public override void Destroy()
140136
private IMixedRealitySpatialAwarenessSystem SpatialAwarenessSystem => spatialAwarenessSystem ?? (spatialAwarenessSystem = MixedRealityToolkit.SpatialAwarenessSystem);
141137

142138
#if UNITY_WSA
139+
/// <inheritdoc />
140+
protected override void Dispose(bool disposing)
141+
{
142+
if (disposed) { return; }
143+
144+
base.Dispose(disposing);
145+
146+
if (IsRunning)
147+
{
148+
Suspend();
149+
}
150+
151+
if (disposing)
152+
{
153+
CleanupObservedObjects();
154+
}
155+
156+
DisposeObserver();
157+
158+
disposed = true;
159+
}
160+
143161
/// <summary>
144162
/// The surface observer providing the spatial data.
145163
/// </summary>
@@ -292,24 +310,23 @@ private void CreateObserver()
292310
/// </summary>
293311
private void CleanupObserver()
294312
{
295-
if (observer != null)
296-
{
297-
if (IsRunning)
298-
{
299-
Suspend();
300-
}
301-
observer.Dispose();
302-
observer = null;
303-
}
313+
// Destroys all observed objects and the observer.
314+
Dispose(true);
315+
}
304316

317+
/// <summary>
318+
/// Cleans up the objects created during observation.
319+
/// </summary>
320+
private void CleanupObservedObjects()
321+
{
305322
if (Application.isPlaying)
306323
{
307324
// Cleanup the scene objects are managing
308325
if (observedObjectParent != null)
309326
{
310327
observedObjectParent.transform.DetachChildren();
311328
}
312-
329+
313330
foreach (SpatialAwarenessMeshObject meshObject in meshes.Values)
314331
{
315332
if (meshObject != null)
@@ -338,6 +355,18 @@ private void CleanupObserver()
338355
}
339356
}
340357

358+
/// <summary>
359+
/// Implements proper cleanup of the SurfaceObserver.
360+
/// </summary>
361+
private void DisposeObserver()
362+
{
363+
if (observer != null)
364+
{
365+
observer.Dispose();
366+
observer = null;
367+
}
368+
}
369+
341370
/// <summary>
342371
/// Requests updates from the surface observer.
343372
/// </summary>

Assets/MixedRealityToolkit.SDK/Features/UX/Interactable/Scripts/Layout/ButtonBackgroundSizeOffset.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Microsoft.MixedReality.Toolkit.SDK.UX.Interactable.Layout
99
{
1010
/// <summary>
1111
/// Scales an object relative the scale of the Anchor Transform
12-
/// Works best when using with Layout3DPixelSize, but not requied - See LayoutPixelSize for more info
12+
/// Works best when using with Layout3DPixelSize, but not required - See LayoutPixelSize for more info
1313
/// Use Case:
1414
/// Create a button, then add another element who's size should maintain a consistent size relative to the Anchor.
1515
/// Like creating a button background using a Cube and ButtonSize. The add another Cube that is 40 pixels smaller than the background.
@@ -20,7 +20,7 @@ public class ButtonBackgroundSizeOffset : MonoBehaviour
2020
{
2121
/// <summary>
2222
/// A scale factor for layout3D, default is based on 2048 pixels to 1 meter.
23-
/// Similar to values used in designer and 2D art programs and helps create consistancy across teams.
23+
/// Similar to values used in designer and 2D art programs and helps create consistency across teams.
2424
/// </summary>
2525
[Tooltip("A pixel to Unity unit conversion, Default: 2048x2048 pixels covers a 1x1 Unity Unit or default primitive size")]
2626
[SerializeField]
@@ -31,7 +31,7 @@ public class ButtonBackgroundSizeOffset : MonoBehaviour
3131
/// </summary>
3232
[Tooltip("The transform this object should be linked and aligned to")]
3333
[SerializeField]
34-
private Transform AnchorTransform;
34+
private Transform AnchorTransform = null;
3535

3636
/// <summary>
3737
/// Make this object's size scaled relative to the Anchor's size

Assets/MixedRealityToolkit.SDK/Features/UX/Interactable/Scripts/Layout/ButtonBorder.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@
88
namespace Microsoft.MixedReality.Toolkit.SDK.UX.Interactable.Layout
99
{
1010
/// <summary>
11-
/// Use a Unity primitive Cube or cylindar as a border segment relative to the scale of the AnchorTransform
11+
/// Use a Unity primitive Cube or cylinder as a border segment relative to the scale of the AnchorTransform
1212
/// Use with ButtonSize on the component and the Anchor for consistent results
13-
/// Works best when using with ButtonSize, but not requied - See ButtonSize for more info.
13+
/// Works best when using with ButtonSize, but not required - See ButtonSize for more info.
1414
/// </summary>
1515
[ExecuteInEditMode]
1616
public class ButtonBorder : MonoBehaviour
1717
{
1818
/// <summary>
1919
/// A scale factor for button layouts, default is based on 2048 pixels to 1 meter.
20-
/// Similar to values used in designer and 2D art programs and helps create consistancy across teams.
20+
/// Similar to values used in designer and 2D art programs and helps create consistency across teams.
2121
///
2222
/// Use Case:
2323
/// A designer created a basic button background using a Cube and ButtonSize
24-
/// Add some more borders, using more cubes or cylenders, that will scale to the edges of the background size
24+
/// Add some more borders, using more cubes or cylinders, that will scale to the edges of the background size
2525
/// </summary>
2626
[Tooltip("A pixel to Unity unit conversion, Default: 2048x2048 pixels covers a 1x1 Unity Unit or default primitive size")]
2727
[SerializeField]
@@ -32,7 +32,7 @@ public class ButtonBorder : MonoBehaviour
3232
/// </summary>
3333
[Tooltip("The transform this object should be linked and aligned to")]
3434
[SerializeField]
35-
private Transform AnchorTransform;
35+
private Transform AnchorTransform = null;
3636

3737
/// <summary>
3838
/// Width of the border
@@ -55,14 +55,14 @@ public class ButtonBorder : MonoBehaviour
5555
/// </summary>
5656
[Tooltip("Where to set this object's center point in relation to the Anchor's center point")]
5757
[SerializeField]
58-
private Vector3 Alignment;
58+
private Vector3 Alignment = Vector3.zero;
5959

6060
/// <summary>
6161
/// An absolute value to offset the border from the Anchor's edge
6262
/// </summary>
6363
[Tooltip("That absolute amount to offset the position")]
6464
[SerializeField]
65-
private Vector3 PositionOffset;
65+
private Vector3 PositionOffset = Vector3.zero;
6666

6767
/// <summary>
6868
/// Overlap the edge it is assigned to so there are not gaps in the corners

Assets/MixedRealityToolkit.SDK/Features/UX/Scripts/Tooltips/ToolTip.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,11 @@ public string ToolTipText
192192

193193
[SerializeField]
194194
[Tooltip("The padding around the content (height / width)")]
195-
private Vector2 backgroundPadding;
195+
private Vector2 backgroundPadding = Vector2.zero;
196196

197197
[SerializeField]
198198
[Tooltip("The offset of the background (x / y / z)")]
199-
private Vector3 backgroundOffset;
199+
private Vector3 backgroundOffset = Vector3.zero;
200200

201201
/// <summary>
202202
/// The offset of the background (x / y / z)

Assets/MixedRealityToolkit.SDK/Features/UX/Scripts/Tooltips/ToolTipBackgroundBlob.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class ToolTipBackgroundBlob : MonoBehaviour, IToolTipBackground
3030
private Transform attachPointOffset = null;
3131

3232
[SerializeField]
33-
private ToolTip toolTip;
33+
private ToolTip toolTip = null;
3434

3535
#endregion Transform Targets
3636

0 commit comments

Comments
 (0)