UI Toolkit and ML Rig

Hi there,

I’ve been trying to use UI Toolkit with Magic Leap 2 recently and I’ve found some issues while using the default ML Rig Prefab. As it is right now, it seems like ML Rig Controller Game Object doesn’t interact with the new UI Toolkit. Is there something missing or am I doing something wrong? From our observations, it seems like it might need the NearFarInteractor.

thank you in advance!

Unity Editor version (if applicable): 6.2
MLSDK version: 2.6.0

Hey @michel.comin ,

Welcome to the Magic Leap Forums!
Sorry you’re running into issues!

To my knowledge, the ML Rig Controller object just needs to have an XR Ray Interactor script on it to enable interactions with UI Components. As long as those UI components can receive raycast interactions, it should be working.

For an example, you can check out the Magic Leap Examples project for Unity.
You can download this project from the MLHub.
Here’s documentation on how to get and setup the project if you like:

Best,
Corey

Hi cfeist,

Just to be clear I’m talking about the new way of doing UI using UI Toolkit. For this new components of UI (that don’t use canvas) the XR Ray Interactor doesn’t work. You can see the actual differences in the XR Interaction Toolkit sample “World Space UI” where they have both UIs (new and old) side by side.

I managed to have it working doing some changes to your ML Rig:

  • Disable all the other scripts of Controller object and (including Line renderer) and adding XR Interaction Group.
  • Add a child GameObject to controller named “near-far interactor” which has the Near-Far Interactor script, Interaction Attach Controller script, Sphere interaction caster and curve interaction caster script
  • Inside the Near-far interactor, add another gameobject with the linevisual, which has a line renderer and a curve visual controller script

there might be a better way, but I based in on that XR Interaction Toolkit sample and this seems to work (besides some weird behavior with the line).