Search code examples
xamarinxamarin.iosscenekitaugmented-realityarkit

Take a screenshot in ARKit


I'm currently making my first ARKit app using Xamarin.

I'm trying to take a capture of the AR view (camera view + 3D scene) for the user to save and share.

As suggested in other posts, I'm using this 'Snapshot' method on my ARSCNView (named SceneView) to get a UIImage and displaying it with a previously created UIImageView, and have been getting this MemberAccessException : MemberAccessException screenshot

The added stacktrace isn't helping : Stacktrace screenshot

It seems like Snapshot is internally trying to create an instance of SCNSceneRenderer, hence the error.


I'm a bit desperate there, you would think taking a picture with your 3D scene in an AR view would be simple and natural..

Any help would be greatly appreciated.


Solution

  • So, I still believe this a Xamarin bug, and have found a workaround.

    I'm referencing UIViews to be hidden from the screenshot in a List ScreenshotHiddable and i'm using the classic UIView.Capture method on my SceneView :

    ScreenshotHiddable.HiddenAll(true);
    UIImage screenshot = SceneView.Capture();
    ScreenshotHiddable.HiddenAll(false);
    

    I'll admit this is a bit ugly, but it's working.