RenderTexture Screenshots

Just wondering if people have been able to get rendertexture screenshots to work in MR mode?

Hi @ina

If you’re having trouble with render textures, first thing to check is that you’re calling MarkDirty() after updating the contents as described in the docs.


Where do you call MarkDirty? Right before renderTexture.Render() (?)

        yield return new WaitForEndOfFrame();
        RenderTexture renderTexture = new RenderTexture(targetWidth, targetHeight, 24);
        targetCamera.targetTexture = renderTexture;
        Texture2D screenshotTexture = new Texture2D(targetWidth, targetHeight, TextureFormat.RGB24, false);
        // Unity.PolySpatial.PolySpatialObjectUtils.MarkDirty(renderTexture);
        targetCamera.Render(); = renderTexture;
        screenshotTexture.ReadPixels(new Rect(0, 0, targetWidth, targetHeight), 0, 0);
        targetCamera.targetTexture = null; = null;

It doesn’t matter, as long as you do it on the same Update in which you change the RenderTexture. The synchronization that PolySpatial performs happens after LateUpdate, and transfers all assets in use that have been marked dirty (and then marks them clean).

since Play to Device doesn’t seem to work anymore do u have any suggestions on how to debug this

Could this also have to do with runtime in-game screenshots not being allowed by apple for privacy reasons?

PolySpatial has no API for obtaining a screenshot from the simulator or device display, and I’m not sure that that’s possible via Apple’s APIs. Any screenshot you may be get from a Unity API (such as ScreenCapture.CaptureScreenshotIntoRenderTexture) would have to be rendered by Unity (meaning that it wouldn’t include the environment from the camera, for instance, or Apple’s image-based lighting), and I suspect those particular APIs wouldn’t work because MR apps run in batch mode and don’t have a normal frame buffer. The only way I’m aware of to render a scene is to render to a RenderTexture using, for example, Camera.Render.

so i just want to render my gameview and not the device camera but somehow rendertextures are not working (all white)

If you submit a bug report with a repro case and let us know the incident number (IN-#####), we can look into what might be going wrong.