Skip to content

Commit 379c274

Browse files
We should only be setting the cursor in Start, not each Enable.
Also waited until the input system is valid before setting the cursor.
1 parent 4c5615b commit 379c274

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

Assets/MixedRealityToolkit-SDK/Features/UX/Scripts/Cursors/BaseCursor.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ public class BaseCursor : InputSystemGlobalListener, IMixedRealityCursor
1818
{
1919
public CursorStateEnum CursorState { get; private set; } = CursorStateEnum.None;
2020

21-
public bool SetVisibilityOnSourceDetected { get; set; } = false;
22-
2321
/// <summary>
2422
/// Surface distance to place the cursor off of the surface at
2523
/// </summary>
@@ -111,6 +109,9 @@ public virtual void SetVisibility(bool visible)
111109
}
112110
}
113111

112+
/// <inheritdoc />
113+
public bool SetVisibilityOnSourceDetected { get; set; } = false;
114+
114115
/// <inheritdoc />
115116
public GameObject GameObjectReference => gameObject;
116117

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
using Microsoft.MixedReality.Toolkit.Core.Interfaces.Physics;
1212
using Microsoft.MixedReality.Toolkit.Core.Interfaces.TeleportSystem;
1313
using Microsoft.MixedReality.Toolkit.Core.Managers;
14+
using Microsoft.MixedReality.Toolkit.Core.Utilities.Async;
1415
using Microsoft.MixedReality.Toolkit.SDK.Input.Handlers;
1516
using System.Collections;
16-
using Microsoft.MixedReality.Toolkit.Core.Utilities.Async;
1717
using UnityEngine;
1818

1919
namespace Microsoft.MixedReality.Toolkit.SDK.UX.Pointers
@@ -129,7 +129,6 @@ public virtual void SetCursor(GameObject newCursor = null)
129129
protected override void OnEnable()
130130
{
131131
base.OnEnable();
132-
SetCursor();
133132

134133
if (MixedRealityManager.IsInitialized && TeleportSystem != null && !lateRegisterTeleport)
135134
{
@@ -147,6 +146,12 @@ protected override async void Start()
147146
lateRegisterTeleport = false;
148147
TeleportSystem.Register(gameObject);
149148
}
149+
150+
if (InputSystem == null)
151+
{
152+
await WaitUntilInputSystemValid;
153+
SetCursor();
154+
}
150155
}
151156

152157
protected override void OnDisable()

Assets/MixedRealityToolkit/_Core/Interfaces/InputSystem/IMixedRealityCursor.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ public interface IMixedRealityCursor : IMixedRealityFocusChangedHandler, IMixedR
4242
/// <param name="visible">True if cursor should be visible, false if not.</param>
4343
void SetVisibility(bool visible);
4444

45+
/// <summary>
46+
/// Sets the visibility of the <see cref="IMixedRealityCursor"/> when the source is detected.
47+
/// </summary>
4548
bool SetVisibilityOnSourceDetected { get; set; }
4649

4750
/// <summary>

0 commit comments

Comments
 (0)