Skip to content

Commit 242f1ac

Browse files
author
David Kline
authored
Merge pull request #3638 from Alexees/mrtk_avoidUnityEditorBug
Mrtk avoid unity editor bug
2 parents bc261c2 + c911e50 commit 242f1ac

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Assets/MixedRealityToolkit.Providers/WindowsMixedReality/WindowsMixedRealityDeviceManager.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ public override void Enable()
269269

270270
interactionmanagerStates = InteractionManager.GetCurrentReading();
271271

272+
// Avoids a Unity Editor bug detecting a controller from the previous run during the first frame
273+
#if !UNITY_EDITOR
272274
// NOTE: We update the source state data, in case an app wants to query it on source detected.
273275
for (var i = 0; i < interactionmanagerStates?.Length; i++)
274276
{
@@ -280,6 +282,7 @@ public override void Enable()
280282
MixedRealityToolkit.InputSystem?.RaiseSourceDetected(controller.InputSource, controller);
281283
}
282284
}
285+
#endif
283286

284287
if (MixedRealityToolkit.Instance.ActiveProfile.IsInputSystemEnabled &&
285288
MixedRealityToolkit.Instance.ActiveProfile.InputSystemProfile.GesturesProfile != null &&
@@ -466,6 +469,15 @@ private void RemoveController(InteractionSource interactionSource)
466469
/// <param name="args">SDK source detected event arguments</param>
467470
private void InteractionManager_InteractionSourceDetected(InteractionSourceDetectedEventArgs args)
468471
{
472+
473+
// Avoids a Unity Editor bug detecting a controller from the previous run during the first frame
474+
#if UNITY_EDITOR
475+
if (Time.frameCount <= 1)
476+
{
477+
return;
478+
}
479+
#endif
480+
469481
bool raiseSourceDetected = !activeControllers.ContainsKey(args.state.source.id);
470482

471483
var controller = GetController(args.state.source);

0 commit comments

Comments
 (0)