/**
     *  Reconfigure XR based on the currently selected options (lighting, camera, surfaces, etc.).
     *  All configuration changes are best-effort based on the setting and device. This means that
     *  changes might take effect immediately (next frame), soon (in a few frames), on camera session
     *  restart (the next call to pause and resume), or never (if a setting is not supported on a given
     *  device).
     */
    public void ConfigureXR()
    {
        if (bridge == null)
        {
            return;
        }

        {
            var configMessageBuilder = new MessageBuilder();
            var config     = configMessageBuilder.initRoot(XRConfiguration.factory);
            var configMask = config.getMask();
            configMask.setLighting(enableLighting);
            configMask.setCamera(enableCamera);
            configMask.setSurfaces(enableSurfaces);
            configMask.setVerticalSurfaces(enableVerticalSurfaces);

            config.getCameraConfiguration().setAutofocus(enableCameraAutofocus);
            config.setMobileAppKey(GetMobileAppKey());

            if (cam != null)
            {
                var graphicsIntrinsicsConfig = config.getGraphicsIntrinsics();
                graphicsIntrinsicsConfig.setTextureWidth((int)cam.pixelRect.width);
                graphicsIntrinsicsConfig.setTextureHeight((int)cam.pixelRect.height);
                graphicsIntrinsicsConfig.setNearClip(cam.nearClipPlane);
                graphicsIntrinsicsConfig.setFarClip(cam.farClipPlane);
                graphicsIntrinsicsConfig.setDigitalZoomHorizontal(1.0f);
                graphicsIntrinsicsConfig.setDigitalZoomVertical(1.0f);
            }

            bridge.CommitConfiguration(configMessageBuilder);
        }

        {
            var configMessageBuilder = new MessageBuilder();
            var config = configMessageBuilder.initRoot(XRConfiguration.factory);

            var coords = config.getCoordinateConfiguration();
            coords.getOrigin().getRotation().setW(facing.w);
            coords.getOrigin().getRotation().setX(facing.x);
            coords.getOrigin().getRotation().setY(facing.y);
            coords.getOrigin().getRotation().setZ(facing.z);
            coords.getOrigin().getPosition().setX(origin.x);
            coords.getOrigin().getPosition().setY(origin.y);
            coords.getOrigin().getPosition().setZ(origin.z);
            coords.setScale(scale);

            bridge.CommitConfiguration(configMessageBuilder);
        }
    }
    private void ConfigureXR()
    {
        if (bridge == null)
        {
            return;
        }

        XRConfigurationRef config = bridge.GetMutableXRConfiguration();

        config.ptr.maskLighting = enableLighting;
        config.ptr.maskCamera   = enableCamera;
        config.ptr.maskSurfaces = enableSurfaces;

        if (cam != null)
        {
            config.ptr.graphicsIntrinsicsTextureWidth          = (int)cam.pixelRect.width;
            config.ptr.graphicsIntrinsicsTextureHeight         = (int)cam.pixelRect.height;
            config.ptr.graphicsIntrinsicsNearClip              = cam.nearClipPlane;
            config.ptr.graphicsIntrinsicsFarClip               = cam.farClipPlane;
            config.ptr.graphicsIntrinsicsDigitalZoomHorizontal = 1.0f;
            config.ptr.graphicsIntrinsicsDigitalZoomVertical   = 1.0f;
        }

        bridge.CommitConfiguration();
    }