Accessing Real RGB Camera in Unity on Magic Leap 2

Hi everyone
I’m new to this area,

I’m trying to access the real RGB camera of Magic Leap 2 through Unity. I want to:

  1. Display the camera feed in a RawImage (or similar UI panel).

  2. Capture a photo and save it to disk.

However, whenever I try to use MLCamera, it always says the API is deprecated. I’m not sure how to proceed using the current Unity SDK.

I’ve seen references to MagicLeap.Android.AndroidCamera, but I’m not sure how to implement it correctly for continuous preview and taking pictures in Unity.

Does anyone have a working approach or example for:

  • Showing the real camera feed in a Unity UI (RawImage or 3D quad)

  • Capturing a still image and saving it

  • Using the current, supported APIs (not deprecated)

Any guidance or example scripts would be really appreciated.

Thanks!

Hey @jose.rodrigues ,

Yes, the MLCamera API is deprecated. You can still use it but you may run into issues.

The current recommended way to capture and visualize the cameras is via the Pixel Sensor API.
Here is some documentation with an example script for exactly what you’re looking for:

Also, you can always take a look at the Magic Leap Examples Unity Project from the MLHub. You can find fully built scenes for various features, including accessing and visualizing a camera stream that you can use as reference.
Just in case you still need to download and try the MLHub, here is the download page for it to get you started!

https://ml2-developer.magicleap.com/downloads

Please let me know if you have anymore questions! Good luck to you with your project.

Best,
Corey