Skip to content

Commit 2890459

Browse files
author
Andrei Borodin
committed
Fixing Teleportation to be visually disabled when the system is disabled in MRTK. Also, fixed another Unity Editor time exception - ArgumentException.
1 parent d9f17a4 commit 2890459

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

Assets/MixedRealityToolkit.SDK/Features/UX/Scripts/Pointers/BaseControllerPointer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ protected override void OnEnable()
129129
{
130130
base.OnEnable();
131131

132-
if (MixedRealityToolkit.IsInitialized && MixedRealityToolkit.TeleportSystem != null && !lateRegisterTeleport)
132+
if (MixedRealityToolkit.IsInitialized && MixedRealityToolkit.Instance.ActiveProfile.IsTeleportSystemEnabled && MixedRealityToolkit.TeleportSystem != null && !lateRegisterTeleport)
133133
{
134134
MixedRealityToolkit.TeleportSystem.Register(gameObject);
135135
}

Assets/MixedRealityToolkit.SDK/Features/UX/Scripts/Pointers/TeleportPointer.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ protected Gradient GetLineGradient(TeleportSurfaceResult targetResult)
101101
#region IMixedRealityPointer Implementation
102102

103103
/// <inheritdoc />
104-
public override bool IsInteractionEnabled => !IsTeleportRequestActive && teleportEnabled;
104+
public override bool IsInteractionEnabled => !IsTeleportRequestActive && teleportEnabled
105+
&& (MixedRealityToolkit.IsInitialized && MixedRealityToolkit.HasActiveProfile && MixedRealityToolkit.Instance.ActiveProfile.IsTeleportSystemEnabled);
105106

106107
/// <inheritdoc />
107108
public override float PointerOrientation
@@ -251,7 +252,11 @@ public override void OnPostRaycast()
251252
public override void OnInputChanged(InputEventData<Vector2> eventData)
252253
{
253254
// Don't process input if we've got an active teleport request in progress.
254-
if (IsTeleportRequestActive) { return; }
255+
if (IsTeleportRequestActive
256+
|| !(MixedRealityToolkit.IsInitialized && MixedRealityToolkit.HasActiveProfile && MixedRealityToolkit.Instance.ActiveProfile.IsTeleportSystemEnabled))
257+
{
258+
return;
259+
}
255260

256261
if (eventData.SourceId == InputSourceParent.SourceId &&
257262
eventData.Handedness == Handedness &&

Assets/MixedRealityToolkit/Inspectors/Profiles/BaseMixedRealityProfileInspector.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ public abstract class BaseMixedRealityProfileInspector : Editor
2828

2929
protected virtual void OnEnable()
3030
{
31+
if (target == null)
32+
{
33+
// Either when we are recompiling, or the inspector window is hidden behind another one, the target can get destroyed (null) and thereby will raise an ArgumentException when accessing serializedObject. For now, just return.
34+
return;
35+
}
36+
3137
targetProfile = serializedObject;
3238
profile = target as BaseMixedRealityProfile;
3339
}

Assets/MixedRealityToolkit/Inspectors/Profiles/MixedRealityToolkitConfigurationProfileInspector.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ protected override void OnEnable()
5656
{
5757
base.OnEnable();
5858

59+
if (target == null)
60+
{
61+
// Either when we are recompiling, or the inspector window is hidden behind another one, the target can get destroyed (null) and thereby will raise an ArgumentException when accessing serializedObject. For now, just return.
62+
return;
63+
}
64+
5965
configurationProfile = target as MixedRealityToolkitConfigurationProfile;
6066

6167
// Create The MR Manager if none exists.

0 commit comments

Comments
 (0)