When Using the following script in the latest Unity magic Leap Examples resulted in a screenshot without any issues. Make sure you request storage permissions
using System.Collections;
using UnityEngine;
public class ScreenshotTest : MonoBehaviour
{
// Call this method to take a screenshot and save it to local app storage
public void Start()
{
StartCoroutine(CaptureScreenshotCoroutine());
}
private IEnumerator CaptureScreenshotCoroutine()
{
yield return new WaitForSeconds(3);
// Define the filename and path for the screenshot
string screenshotFilename = "screenshot.png";
string screenshotPath = Application.persistentDataPath + "/" + screenshotFilename;
// Capture the screenshot
ScreenCapture.CaptureScreenshot(screenshotFilename);
// Wait for the end of the frame to ensure the screenshot has been captured
yield return new WaitForEndOfFrame();
// Optionally, output the screenshot path to the console
Debug.Log("Screenshot saved to: " + screenshotPath);
}
}