Skip to content

Commit a299d00

Browse files
author
David Kline (ANALOG)
committed
update teleport system
1 parent f2162c9 commit a299d00

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

Assets/MixedRealityToolkit.Services/TeleportSystem/MixedRealityTeleportSystem.cs

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

44
using Microsoft.MixedReality.Toolkit.Core.EventDatum.Teleport;
5+
using Microsoft.MixedReality.Toolkit.Core.Interfaces;
56
using Microsoft.MixedReality.Toolkit.Core.Interfaces.InputSystem;
67
using Microsoft.MixedReality.Toolkit.Core.Interfaces.TeleportSystem;
78
using Microsoft.MixedReality.Toolkit.Core.Services;
@@ -14,8 +15,16 @@ namespace Microsoft.MixedReality.Toolkit.Services.Teleportation
1415
/// <summary>
1516
/// The Mixed Reality Toolkit's specific implementation of the <see cref="Microsoft.MixedReality.Toolkit.Core.Interfaces.TeleportSystem.IMixedRealityTeleportSystem"/>
1617
/// </summary>
17-
public class MixedRealityTeleportSystem : BaseEventSystem, IMixedRealityTeleportSystem
18+
public class MixedRealityTeleportSystem : BaseCoreSystem, IMixedRealityTeleportSystem
1819
{
20+
public MixedRealityTeleportSystem(
21+
IMixedRealityServiceRegistrar registrar,
22+
Transform playspace) : base(registrar, null) // Teleport system does not use a profile
23+
{
24+
Playspace = playspace;
25+
IsInputSystemEnabled = (registrar.GetService<IMixedRealityInputSystem>(showLogs: false) != null);
26+
}
27+
1928
private TeleportEventData teleportEventData;
2029

2130
private bool isTeleporting = false;
@@ -47,7 +56,7 @@ private void InitializeInternal()
4756

4857
if (eventSystems.Length == 0)
4958
{
50-
if (!MixedRealityToolkit.Instance.ActiveProfile.IsInputSystemEnabled)
59+
if (!IsInputSystemEnabled)
5160
{
5261
eventSystemReference = new GameObject("Event System");
5362
eventSystemReference.AddComponent<EventSystem>();
@@ -123,6 +132,16 @@ public override void Unregister(GameObject listener)
123132

124133
#region IMixedRealityTeleportSystem Implementation
125134

135+
/// <summary>
136+
/// The transform of the playspace scene object.
137+
/// </summary>
138+
private Transform Playspace = null;
139+
140+
/// <summary>
141+
/// Is there an input system registered.
142+
/// </summary>
143+
private bool IsInputSystemEnabled = false;
144+
126145
private float teleportDuration = 0.25f;
127146

128147
/// <inheritdoc />
@@ -237,7 +256,7 @@ private void ProcessTeleportationRequest(TeleportEventData eventData)
237256
{
238257
isProcessingTeleportRequest = true;
239258

240-
var cameraParent = MixedRealityToolkit.Instance.MixedRealityPlayspace;
259+
var cameraParent = Playspace;
241260

242261
targetRotation = Vector3.zero;
243262
targetRotation.y = eventData.Pointer.PointerOrientation;

Assets/MixedRealityToolkit/Services/MixedRealityToolkit.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ private void InitializeServiceLocator()
386386
{
387387
object[] args = { this, ActiveProfile.BoundaryVisualizationProfile, Instance.MixedRealityPlayspace, ActiveProfile.TargetExperienceScale };
388388

389-
if (!RegisterService<IMixedRealityBoundarySystem>(ActiveProfile.BoundarySystemSystemType, args : args) || BoundarySystem == null)
389+
if (!RegisterService<IMixedRealityBoundarySystem>(ActiveProfile.BoundarySystemSystemType, args: args) || BoundarySystem == null)
390390
{
391391
Debug.LogError("Failed to start the Boundary System!");
392392
}
@@ -407,7 +407,9 @@ private void InitializeServiceLocator()
407407
// If the Teleport system has been selected for initialization in the Active profile, enable it in the project
408408
if (ActiveProfile.IsTeleportSystemEnabled)
409409
{
410-
if (!RegisterService<IMixedRealityTeleportSystem>(ActiveProfile.TeleportSystemSystemType) || TeleportSystem == null)
410+
object[] args = { this, Instance.MixedRealityPlayspace };
411+
412+
if (!RegisterService<IMixedRealityTeleportSystem>(ActiveProfile.TeleportSystemSystemType, args: args) || TeleportSystem == null)
411413
{
412414
Debug.LogError("Failed to start the Teleport System!");
413415
}
@@ -417,7 +419,7 @@ private void InitializeServiceLocator()
417419
{
418420
object[] args = { this, ActiveProfile.DiagnosticsSystemProfile, Instance.MixedRealityPlayspace };
419421

420-
if (!RegisterService<IMixedRealityDiagnosticsSystem>(ActiveProfile.DiagnosticsSystemSystemType, args : args) || DiagnosticsSystem == null)
422+
if (!RegisterService<IMixedRealityDiagnosticsSystem>(ActiveProfile.DiagnosticsSystemSystemType, args: args) || DiagnosticsSystem == null)
421423
{
422424
Debug.LogError("Failed to start the Diagnostics System!");
423425
}

0 commit comments

Comments
 (0)