Unity Android plugin for retrieving the latest screenshot images from Meta Quest. It can be combined with passthrough to capture camera images.
- Meta Quest Pro
- Unity Editor 2022.3.1.f1
- Place the files in the
Assets
folder. - Choose
File
>Build Settings
from the menu bar, click on Android in the Platform tab, and press theSwitch Platform
button. - Press the
Player Settings
button, checkCustom Main Manifest
,Custom Main Gradle Template
, andCustom Gradle Properties Template
underPublishing Settings
>Build
. - Edit the files generated in step 3 as follows:
Assets/Plugins/Android/AndroidManifest.xml
- Add the following tags below the manifest tag:
<manifest ... ... > <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" /> <uses-permission android:name="com.oculus.permission.SET_VR_DEVICE_PARAMS" /> <uses-permission android:name="com.oculus.permission.READ_VR_DEVICE_PARAMS" />
- Add the following tags below the manifest tag:
Assets/Plugins/Android/mainTemplate.gradle
- Add dependencies at the bottom of the file:
dependencies { implementation 'androidx.appcompat:appcompat:1.6.1' }
- Add dependencies at the bottom of the file:
Assets/Plugins/Android/gradleTemplate.properties
- Add the following:
android.useAndroidX=true android.enableJetifier=true
- Add the following:
- Refer to the files in the included Plugins directory as a sample.
- Place a suitable canvas in the scene, and add a button for requesting storage access (
Request Permission Button
) and a button for loading screenshots (Load Screenshot Button
). - Place a
RawImage
for displaying the received texture in the scene. - Add the
ScreenshotLoader
component to a suitable game object and configure it with the UI added in steps 1 and 2.
- If the app does not have storage access permission, the
Request Permission Button
is displayed. Click it and grant permission from the system dialog that appears. - Capture a screenshot of the screen by simultaneously pressing the Oculus button and trigger button on the right controller.
- To capture camera images, see details below.
- Press the
Load Screenshot Button
to load the screenshot.
- The
screenshotBytes
inside theloadScreenShot()
method of theScreenshotLoader
instance contains the binary data of the image (JPEG). Modify the subsequent processing to use it. - As
loadScreenShot()
is executed on the same thread as the call, it can be called from Unity's main thread, allowing scene manipulation.
To capture camera images, there are two methods:
- Launch passthrough from the system, and capture camera images by simultaneously pressing the Oculus button and trigger button on the right controller.
- Introduce the Passthrough API, display passthrough within the app, and capture camera images by simultaneously pressing the Oculus button and trigger button on the right controller.
Check out a sample project here