Magic leap simmulator is constantly crashing unity editor

Hey all!
I'm experiencing constant crashes of the unity editor while using the magic leap simulator in unity in play mode. It comes to a point where it's not even possible to use since it always crashes without any warning or crash message from unity after a minute or two. I would be happy for help with this. The simulator version is 3.9.0.20240312.

Unity Editor version: 2022.3.16.f1
ML2 OS version: 1.9
Unity SDK version:1.12.1
Host OS: Windows

Hi @GalLibba,

Magic Leap Simulator is now deprecated and no longer supported. For simulating XR experiences, we recommend Unity's XR Device simulator. If you're using MRTK, we also recommend Input simulation - MRTK3.

Let me know if you have any further questions.

Thank you for the answer @etucker!
However I'm not sure i fully understand how it works. I did the following in my project:

  • Deleted the magic leap simulator package from the package manager.
  • Imported the XR device simulator from the xr interaction toolkit.
  • dragged both MRTKInputSimulator prefab and XRDeviceSimulator to my scene.

When entering playmode I get this warning:
"No magic leap app simulator session is running.Exit play mode and start App simulator before entering play mode again."

If i press okay i get multiple errors and the simulator is not really matching magic leap layout. what am i missing here?

Please try using the latest version of the Unity SDK and OpenXR workflow instead of the legacy MLSDK.

You can also disable Magic Leap Simulator from your Project settings

Edit > Project Settings , then XR Plug-in Management, then select the standalone tab and finally make sure Magic Leap is disabled for the standalone platform.

@GalLibba

Just to clarify, I think the recommendation is to use either the XR Input Simulator or the MRTK Input Simulator, not both at the same time. I believe the XR Input Simulator and MRTK Input Simulator will conflict and would try to control the same device simulation, which wouldn't work well from what I understand.

If your project contains MRTK3, and you are using the MRTK3 rig, I would definitely recommend just using the MRTK Input Simulator. Also, if you have our latest Magic Leap MRTK3 package, version 1.3.0, we recently added input simulation for the Magic Leap 2 Controller. Here are the ML Input Simulation input instructions. To use, you can enable the Magic Leap Input Simulation to be automatically added to the scene in Editor Play mode in our MRTK3 Settings (see below), or manually add the MagicLeapInputSImulator prefab to the scene along with the MRTKInputSimulator prefab.

1 Like

Thank you guys, i did as you both suggested. Updated the MRTK3 package and MLSDK.
The simulator seems to work and its very nice! I have two questions tough:
First I cant seem to get any input from the controller in my scripts. I have a controller input manager that triggers events in my scene, It was working in the previous simulator but now It does not seem to be working.
In addition, is there anyway to simulate marker tracking like in the old simulator?

@GalLibba

Can you please share how you obtain controller input in your scripts? That might help figure out why that isn't working currently with the MRTK3 and MagicLeap MRTK3 simulator. If you use one of the provided input action maps and create an instance in code, that should work.

As for marker tracking, I don't personally know what the recommendation is to simulate those currently, and would let DevRel answer that.

@whebert
So basically, I Create a MagicLeapInputs and ControllerActions instances, I then subscribe to events of the button i need. It looks somewhat like this:

void Start()
{
    _mlInputs = new MagicLeapInputs();

    _mlInputs.Enable();

    _MLControllerActions = new MagicLeapInputs.ControllerActions(_mlInputs);

    _MLControllerActions.Bumper.performed += HandleBumperPress();

    _MLControllerActions.Bumper.canceled += HandleBumperRelease();
}

private void HandleBumperPress(InputAction.CallbackContext context)
{
   Logger.Print($"{BUMPER} {WAS_PRESSED}");

   if (!IsInputPressValid(ControllerButtons.Bumper)) return;

   InActiveInput = true;

   OnBumperPerformed.Invoke(this, null);
}

private void HandleBumperRelease(InputAction.CallbackContext context)
{
    Logger.Print($"{BUMPER} {WAS_RELEASED}");

    if (!IsInputReleaseValid(ControllerButtons.Bumper)) return;

    InActiveInput = false;

    OnBumperRelease.Invoke(this, null);
}

Unfortunately you will not be able to simulate marker tracking in editor.


Regarding the Input actions.

The script you posted looks like it's referencing the Input Actions from the MLSDK. Make sure you are using the Input actions that are bound to the OpenXR Input Paths (aka using MagicLeapInputsOpenXR or the more XRController/ Input action paths.

@GalLibba

Just a quick question, are you using the legacy MagicLeap XR provider, or have you transitioned to using the OpenXR provider?

In XR Plug-In Management:


Or

It should be able to work either way, but the recommendation to fix varies depending...

1 Like

@GalLibba

Oh wait, I see you are using SDK 1.12.1, sorry didn't catch that initially - that would mean the legacy ML XR Provider. Gotcha.

I'll write up a way to have that script working, let me verify with that configuration.

@GalLibba

OK, the legacy MagicLeapInputs input actions that come with SDK 1.12.1, do still work with our MagicLeapInputSimulator in MRTK3. However, it may need a smallish tweak in your script to get it working so that it works in Editor play mode with the simulator and, of course, on device.

TLDR: The reason it isn't working right away is that the MagicLeapInputSimulator device provides actions that bind better to the OpenXR input actions, and not the legacy MagicLeapInputs actions. However, we did accommodate for this in the simulator by overriding the legacy action paths to be able to bind to the same actions as OpenXR when running in Editor play mode with the simulator active. It just seems you need to use references to the input actions instead of creating the map directly in code. But the end result is very similar (see below) and works in either Editor play mode or on device:

[SerializeField]
private InputActionProperty _MLControllerBumper;

[SerializeField]
private InputActionProperty _MLControllerMenu;

void Start()
{
    // Enable the InputActionMap so all actions within are enabled, similar to _mlInputs.Enable();
    _MLControllerBumper.action?.actionMap?.Enable();

    _MLControllerBumper.action.performed += HandleBumperPress;

    _MLControllerBumper.action.canceled += HandleBumperRelease;

    _MLControllerMenu.action.performed += HandleMenuPress;

    _MLControllerMenu.action.canceled += HandleMenuRelease;
}

private void HandleBumperPress(InputAction.CallbackContext context)
{
    Debug.Log("Bumper Was Pressed");
}
private void HandleBumperRelease(InputAction.CallbackContext context)
{
    Debug.Log("Bumper Was Released");
}

private void HandleMenuPress(InputAction.CallbackContext context)
{
    Debug.Log("Menu Was Pressed");
}

private void HandleMenuRelease(InputAction.CallbackContext context)
{
    Debug.Log("Menu Was Released");
}

In the above script, you expose an InputActionProperty that you can wire up directly in the Inspector like so (check Use Reference and drag the input action from the MagicLeapInputs (or whatever input action asset) into the Reference field:

Doing it this way seems to allow the path override that we do in the MagicLeapInputSimulator to work so the simulated device properly binds to these legacy actions and you can subscribe to them. This should work on device too of course.

So in Editor play mode, when using the MagicLeapInputSimulator on screen controls, when I hit the Bumper and Menu buttons, I get the following in Console:


If you ever decide to update the project to latest SDK (currently 2.5.0) and transition to OpenXR, the above would still work, you would just drag the input actions from the OpenXR input action asset instead. In the MRTK3 package, we provide an input action asset for OpenXR located at: Packages/Magic Leap MRTK3/Runtime/XRProviders/OpenXR/Input/Actions/MagicLeapInputsOpenXR.inputactions.

Or, since there is no path override needed for the OpenXR actions, you could continue to create the maps directly in code as before, just using the OpenXR action classes instead like so (but only if transitioned to using OpenXR):

using UnityEngine;
using UnityEngine.InputSystem;
using MagicLeap.MRTK.Input;

public class ControllerTest : MonoBehaviour
{
    private MagicLeapInputsOpenXR _mlInputs = null;
    private MagicLeapInputsOpenXR.ControllerActions _MLControllerActions;

    void Start()
    {
        _mlInputs = new MagicLeapInputsOpenXR();

        _mlInputs.Enable();

        _MLControllerActions = new MagicLeapInputsOpenXR.ControllerActions(_mlInputs);

        _MLControllerActions.Bumper.performed += HandleBumperPress;

        _MLControllerActions.Bumper.canceled += HandleBumperRelease;
    }
2 Likes

@whebert
Sorry for the late response, thank you for the help!

@GalLibba

No worries. Were you able to get your script to function with Controller input in simulator and on device as expected again?