### Install Git LFS for Repository Cloning Source: https://github.com/oculus-samples/unity-passthroughcameraapisamples/blob/main/README.md This command installs Git Large File Storage, which is required to properly clone the Unity-PassthroughCameraAPISamples repository due to its large files. ```Git git lfs install ``` -------------------------------- ### Unity Project Configuration for Passthrough Camera API Source: https://github.com/oculus-samples/unity-passthroughcameraapisamples/blob/main/README.md This section outlines the essential steps to configure a Unity project to integrate and utilize the Passthrough Camera API, including project setup, adding necessary building blocks, and incorporating the WebCamTextureManagerPrefab. ```APIDOC Project Setup Steps: - Open Project: Unity 2022.3.58f1 or Unity 6000.0.38f1 - Project Configuration: Meta > Tools > Project Setup Tool (fix issues) - Scene Setup: - Create new empty scene - Add Camera Rig building blocks (Meta > Tools > Building Blocks) - Integrate WebCamTextureManagerPrefab (drag and drop into scene) ``` -------------------------------- ### Clone Unity Passthrough Camera API Samples Repository Source: https://github.com/oculus-samples/unity-passthroughcameraapisamples/blob/main/README.md This command clones the Unity-PassthroughCameraApiSamples repository from GitHub, downloading all project files and history to your local machine. ```Git git clone https://github.com/oculus-samples/Unity-PassthroughCameraApiSamples ``` -------------------------------- ### WebCamTextureManager Script Responsibilities Source: https://github.com/oculus-samples/unity-passthroughcameraapisamples/blob/main/README.md Explains the primary responsibilities of the WebCamTextureManager script, including the lifecycle management of the WebCamTexture object (initialization, stopping, and disposal) and its role in handling camera permissions. ```APIDOC Script: WebCamTextureManager Core Responsibilities: - Initialization: Initializes the WebCamTexture object to access camera data. - Lifecycle Management: Stops and disposes of the WebCamTexture object when the scene is unloaded or application closed. Permission Handling: - Contains PassthroughCameraPermissions C# class. - PassthroughCameraPermissions: Responsible for requesting necessary permissions (android.permission.CAMERA, horizonos.permission.HEADSET_CAMERA). ``` -------------------------------- ### Convert 2D Screen Point to 3D World Ray and Raycast in C# Source: https://github.com/oculus-samples/unity-passthroughcameraapisamples/blob/main/README.md This C# snippet demonstrates how to convert a 2D screen coordinate (e.g., from a detected object) into a 3D ray in world space using PassthroughCameraUtils. It then uses EnvironmentRaycastManager to perform a raycast against the physical environment, finding the exact 3D hit point and normal to place a GameObject. ```csharp var cameraScreenPoint = new Vector2Int(x, y); var ray = PassthroughCameraUtils.ScreenPointToRayInWorld(PassthroughCameraEye.Left, cameraScreenPoint); if (environmentRaycastManager.Raycast(ray, out EnvironmentRaycastHit hitInfo)) { // Place a GameObject at the hit point (position) and rotation (normal) anchorGo.transform.SetPositionAndRotation( hitInfo.point, Quaternion.LookRotation(hitInfo.normal, Vector3.up)); } ``` -------------------------------- ### Save Android Device Logs to File Source: https://github.com/oculus-samples/unity-passthroughcameraapisamples/blob/main/README.md This command captures logcat output from a connected Android device and redirects it to a specified text file. This is useful for debugging applications running on Meta Quest devices by collecting detailed system and application logs. ```Shell adb logcat >> log.txt ``` -------------------------------- ### Granting Headset Camera Permission via ADB Source: https://github.com/oculus-samples/unity-passthroughcameraapisamples/blob/main/README.md This command grants the `horizonos.permission.HEADSET_CAMERA` permission to a specified Android application package via ADB. It is useful for re-granting permissions after initial failures or when re-installing the app is not feasible. Replace `{PACKAGE.NAME}` with your application's actual package identifier, which can be found in Unity's Player Settings. ```Shell adb shell pm grant {PACKAGE.NAME} com.horizonos.permission.HEADSET_CAMERA ``` -------------------------------- ### PassthroughCameraUtils Class API Reference Source: https://github.com/oculus-samples/unity-passthroughcameraapisamples/blob/main/README.md The PassthroughCameraUtils class provides utility methods for working with the Passthrough Camera API, specifically for converting 2D camera data into 3D world space information. It offers functions to retrieve camera resolutions, intrinsic parameters, world poses, and to convert screen points to world rays. ```APIDOC class PassthroughCameraUtils: GetOutputSizes(cameraEye: PassthroughCameraEye) -> List Retrieves a list of all supported resolutions for the specified camera eye. GetCameraIntrinsics(cameraEye: PassthroughCameraEye) -> PassthroughCameraIntrinsics Returns the camera’s intrinsic parameters, including focal length, principal point, resolution, and skew. GetCameraPoseInWorld(cameraEye: PassthroughCameraEye) -> Pose Provides the most recent world pose of the passthrough camera. ScreenPointToRayInWorld(cameraEye: PassthroughCameraEye, screenPoint: Vector2Int) -> Ray Converts a 2D screen coordinate into a 3D ray in world space, starting from the camera's origin. ``` -------------------------------- ### Accessing Camera Texture and Managing Permissions in Unity Source: https://github.com/oculus-samples/unity-passthroughcameraapisamples/blob/main/README.md Details how to programmatically access the camera texture using WebCamTextureManager and its WebCamTexture property. It also specifies the required Android and Horizon OS permissions and how to retrieve supported camera resolutions. ```APIDOC Class: WebCamTextureManager Properties: WebCamTexture: UnityEngine.WebCamTexture Description: Provides access to the camera texture data. Availability: Valid and non-null after permissions granted and texture initialized. Usage Example: Assign to RawImage.texture for display. Class: PassthroughCameraUtils Methods: GetOutputSizes(): List Description: Returns a list of supported camera resolutions. Supported Resolutions: 320x240, 640x480, 800x600, 1280x960. Permissions: Required Permissions: - android.permission.CAMERA - horizonos.permission.HEADSET_CAMERA Permission Management: - Handled by PassthroughCameraPermissions C# class. - Utilizes UnityEngine.Android.Permission (note: handles one request at a time). ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.