Skip to content

Commit 35ab290

Browse files
author
David Kline
authored
Merge pull request #1 from StephenHodgson/vNEXT-Boundary
Boundary Change Requests
2 parents 0820083 + fe93363 commit 35ab290

28 files changed

+364
-325
lines changed

Assets/MixedRealityToolkit-Examples/Demos/Boundary/Scenes/BoundaryVisualization.unity

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,6 @@ GameObject:
338338
m_Component:
339339
- component: {fileID: 353698135}
340340
- component: {fileID: 353698136}
341-
- component: {fileID: 353698138}
342-
- component: {fileID: 353698137}
343341
m_Layer: 0
344342
m_Name: BoundaryVisualizer
345343
m_TagString: Untagged
@@ -371,30 +369,6 @@ MonoBehaviour:
371369
m_Script: {fileID: 11500000, guid: 647fd3dd3cb11e749850897a69f040db, type: 3}
372370
m_Name:
373371
m_EditorClassIdentifier:
374-
--- !u!114 &353698137
375-
MonoBehaviour:
376-
m_ObjectHideFlags: 0
377-
m_PrefabParentObject: {fileID: 0}
378-
m_PrefabInternal: {fileID: 0}
379-
m_GameObject: {fileID: 353698134}
380-
m_Enabled: 1
381-
m_EditorHideFlags: 0
382-
m_Script: {fileID: 11500000, guid: 3bfc11696910c3a4a95bec35024e1ce0, type: 3}
383-
m_Name:
384-
m_EditorClassIdentifier:
385-
isPlayAreaVisualized: 1
386-
--- !u!114 &353698138
387-
MonoBehaviour:
388-
m_ObjectHideFlags: 0
389-
m_PrefabParentObject: {fileID: 0}
390-
m_PrefabInternal: {fileID: 0}
391-
m_GameObject: {fileID: 353698134}
392-
m_Enabled: 1
393-
m_EditorHideFlags: 0
394-
m_Script: {fileID: 11500000, guid: 85c42b1383d59b344b03d394b4d43861, type: 3}
395-
m_Name:
396-
m_EditorClassIdentifier:
397-
isFloorPlaneVisualized: 1
398372
--- !u!1 &1229001241
399373
GameObject:
400374
m_ObjectHideFlags: 0

Assets/MixedRealityToolkit-Examples/Demos/Boundary/Scripts/BoundaryIndicatorDemo.cs

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

44
using Microsoft.MixedReality.Toolkit.Internal.Definitions.BoundarySystem;
5-
using Microsoft.MixedReality.Toolkit.Internal.Interfaces;
5+
using Microsoft.MixedReality.Toolkit.Internal.EventDatum.Boundary;
6+
using Microsoft.MixedReality.Toolkit.Internal.Interfaces.BoundarySystem;
67
using Microsoft.MixedReality.Toolkit.Internal.Managers;
8+
using System.Collections.Generic;
79
using UnityEngine;
810
using UnityEngine.Experimental.XR;
911

@@ -12,22 +14,63 @@ namespace Microsoft.MixedReality.Toolkit.Examples.Demos
1214
/// <summary>
1315
/// Demo class to show different ways of using the boundary API.
1416
/// </summary>
15-
public class BoundaryIndicatorDemo : MonoBehaviour
17+
public class BoundaryIndicatorDemo : MonoBehaviour, IMixedRealityBoundaryHandler
1618
{
17-
/// <summary>
18-
/// Boundary system implementation.
19-
/// </summary
20-
private IMixedRealityBoundarySystem boundaryManager = null;
2119
private IMixedRealityBoundarySystem BoundaryManager => boundaryManager ?? (boundaryManager = MixedRealityManager.Instance.GetManager<IMixedRealityBoundarySystem>());
20+
private IMixedRealityBoundarySystem boundaryManager = null;
21+
22+
private readonly List<GameObject> markers = new List<GameObject>();
23+
24+
#region MonoBehaviour Implementation
25+
26+
private void OnEnable()
27+
{
28+
BoundaryManager.Register(gameObject);
29+
}
2230

2331
private void Start()
2432
{
25-
if (MixedRealityManager.HasActiveProfile && MixedRealityManager.Instance.ActiveProfile.IsBoundarySystemEnabled)
33+
if (BoundaryManager != null && BoundaryManager.EnablePlatformBoundaryRendering)
34+
{
35+
if (markers.Count == 0)
36+
{
37+
AddIndicators();
38+
}
39+
}
40+
}
41+
42+
private void OnDisable()
43+
{
44+
BoundaryManager.Unregister(gameObject);
45+
}
46+
47+
#endregion MonoBehaviour Implementation
48+
49+
#region IMixedRealityBoundaryHandler Implementation
50+
51+
/// <inheritdoc />
52+
public void OnBoundaryVisualizationChanged(BoundaryEventData eventData)
53+
{
54+
if (eventData.IsPlatformRenderingEnabled)
2655
{
27-
AddIndicators();
56+
if (markers.Count == 0)
57+
{
58+
AddIndicators();
59+
}
60+
}
61+
else
62+
{
63+
for (int i = 0; i < markers.Count; i++)
64+
{
65+
Destroy(markers[i]);
66+
}
67+
68+
markers.Clear();
2869
}
2970
}
3071

72+
#endregion IMixedRealityBoundaryHandler Implementation
73+
3174
/// <summary>
3275
/// Displays the boundary as an array of spheres where spheres in the
3376
/// bounds are a different color.
@@ -39,7 +82,8 @@ private void AddIndicators()
3982
float angleRect;
4083
float widthRect;
4184
float heightRect;
42-
if ((BoundaryManager == null) || !BoundaryManager.TryGetRectangularBoundsParams(out centerRect, out angleRect, out widthRect, out heightRect))
85+
86+
if (!BoundaryManager.TryGetRectangularBoundsParams(out centerRect, out angleRect, out widthRect, out heightRect))
4387
{
4488
// If we have no boundary manager or rectangular bounds we will show no indicators
4589
return;
@@ -87,6 +131,8 @@ private void AddIndicators()
87131
}
88132

89133
marker.GetComponent<MeshRenderer>().sharedMaterial = material;
134+
135+
markers.Add(marker);
90136
}
91137
}
92138
}

Assets/MixedRealityToolkit-SDK/Features/Boundary/Components/Scripts/FloorPlaneVisualizer.cs

Lines changed: 0 additions & 83 deletions
This file was deleted.

Assets/MixedRealityToolkit-SDK/Features/Boundary/Components/Scripts/PlayAreaVisualizer.cs

Lines changed: 0 additions & 105 deletions
This file was deleted.

Assets/MixedRealityToolkit-SDK/Features/Boundary/Components.meta renamed to Assets/MixedRealityToolkit-SDK/Features/Boundary/Prefabs.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/MixedRealityToolkit-SDK/Features/Boundary/System/README.md renamed to Assets/MixedRealityToolkit-SDK/Features/Boundary/README.md

File renamed without changes.

Assets/MixedRealityToolkit-SDK/Features/Boundary/System/README.md.meta renamed to Assets/MixedRealityToolkit-SDK/Features/Boundary/README.md.meta

File renamed without changes.

Assets/MixedRealityToolkit-SDK/Features/Boundary/Components/Scripts.meta renamed to Assets/MixedRealityToolkit-SDK/Features/Boundary/Scripts.meta

File renamed without changes.

0 commit comments

Comments
 (0)