|
4 | 4 | using Microsoft.MixedReality.Toolkit.Internal.Definitions; |
5 | 5 | using Microsoft.MixedReality.Toolkit.Internal.Definitions.Utilities; |
6 | 6 | using Microsoft.MixedReality.Toolkit.Internal.Interfaces; |
| 7 | +using System; |
7 | 8 | using System.Collections.Generic; |
8 | 9 | using UnityEngine; |
9 | 10 | using UnityEngine.Experimental.XR; |
@@ -99,9 +100,29 @@ private void CalculateBoundaryBounds() |
99 | 100 | /// </summary> |
100 | 101 | private void SetTrackingSpace() |
101 | 102 | { |
102 | | - // In current versions of Unity, there are two types of tracking spaces. For boundaries, everything other |
103 | | - // than ExpereinceScale.Room currently maps to TrackingSpaceType.Stationary. |
104 | | - TrackingSpaceType trackingSpace = (Scale == ExperienceScale.Room) ? TrackingSpaceType.RoomScale : TrackingSpaceType.Stationary; |
| 103 | + TrackingSpaceType trackingSpace; |
| 104 | + |
| 105 | + // In current versions of Unity, there are two types of tracking spaces. For boundaries, if the scale |
| 106 | + // is not Room or Standing, it currently maps to TrackingSpaceType.Stationary. |
| 107 | + switch (Scale) |
| 108 | + { |
| 109 | + case ExperienceScale.Standing: |
| 110 | + case ExperienceScale.Room: |
| 111 | + trackingSpace = TrackingSpaceType.RoomScale; |
| 112 | + break; |
| 113 | + |
| 114 | + case ExperienceScale.OrientationOnly: |
| 115 | + case ExperienceScale.Seated: |
| 116 | + case ExperienceScale.World: |
| 117 | + trackingSpace = TrackingSpaceType.Stationary; |
| 118 | + break; |
| 119 | + |
| 120 | + default: |
| 121 | + trackingSpace = TrackingSpaceType.Stationary; |
| 122 | + Debug.LogWarning("Unknown / unsupported ExperienceScale. Defaulting to Stationary tracking space."); |
| 123 | + break; |
| 124 | + } |
| 125 | + |
105 | 126 | XRDevice.SetTrackingSpaceType(trackingSpace); |
106 | 127 | } |
107 | 128 |
|
|
0 commit comments