Class XRCameraExtensions | Package Manager UI website
docs.unity3d.com
    Show / Hide Table of Contents

    Class XRCameraExtensions

    Provides extensions to the XRCameraSubsystem.

    Inheritance
    System.Object
    XRCameraExtensions
    Inherited Members
    System.Object.ToString()
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace: UnityEngine.XR.ARExtensions
    Syntax
    public static class XRCameraExtensions

    Methods

    ActivateExtensions(XRCameraSubsystem)

    For internal use. Sets the active subsystem whose extension methods should be used.

    Declaration
    public static void ActivateExtensions(this XRCameraSubsystem cameraSubsystem)
    Parameters
    Type Name Description
    XRCameraSubsystem cameraSubsystem

    The XRCameraSubsystem being extended.

    Configurations(XRCameraSubsystem)

    Enumerate the CameraConfigurations supported by the device.

    Declaration
    public static CameraConfigurationCollection Configurations(this XRCameraSubsystem cameraSubsystem)
    Parameters
    Type Name Description
    XRCameraSubsystem cameraSubsystem

    The XRCameraSubsystem being extended.

    Returns
    Type Description
    CameraConfigurationCollection

    A CameraConfigurationCollection, which allows you to enumerate the supported configurations.

    Examples

    You can use Configurations(XRCameraSubsystem) in a foreach statement:

    foreach (var config in cameraSubsystem.Configurations())
        Debug.Log(config);

    GetCurrentConfiguration(XRCameraSubsystem)

    Get the current CameraConfiguration. If camera configurations are not supported, or if the session is not active, this method may throw InvalidOperationException.

    Camera configurations are unsupported if returns a collection with count of zero.

    Declaration
    public static CameraConfiguration GetCurrentConfiguration(this XRCameraSubsystem cameraSubsystem)
    Parameters
    Type Name Description
    XRCameraSubsystem cameraSubsystem

    The XRCameraSubsystem being extended.

    Returns
    Type Description
    CameraConfiguration

    The currently active CameraConfiguration.

    GetNativePtr(XRCameraSubsystem)

    Retrieve a native IntPtr associated with the XRCameraSubsystem.

    Declaration
    public static IntPtr GetNativePtr(this XRCameraSubsystem cameraSubsystem)
    Parameters
    Type Name Description
    XRCameraSubsystem cameraSubsystem

    The XRCameraSubsystem being extended.

    Returns
    Type Description
    IntPtr

    An IntPtr associated with cameraSubsystem.

    IsPermissionGranted(XRCameraSubsystem)

    Allows you to determine whether camera permission has been granted.

    Declaration
    public static bool IsPermissionGranted(this XRCameraSubsystem cameraSubsystem)
    Parameters
    Type Name Description
    XRCameraSubsystem cameraSubsystem

    The XRCameraSubsystem being extended.

    Returns
    Type Description
    System.Boolean

    True if camera permission has been granted for this app, false otherwise.

    RegisterCameraConfigApi(String, ICameraConfigApi)

    Allows a camera provider to register support for ICameraConfigApi. This is typically only used by platform-specific packages.

    Declaration
    public static void RegisterCameraConfigApi(string subsystemId, ICameraConfigApi api)
    Parameters
    Type Name Description
    System.String subsystemId

    The string name associated with the camera provider to extend.

    ICameraConfigApi api

    The API to use to perform provider-specific calls.

    RegisterCameraImageApi(String, ICameraImageApi)

    Allows a camera provider to register support for ICameraImageApi. This is typically only used by platform-specific packages.

    Declaration
    public static void RegisterCameraImageApi(string subsystemId, ICameraImageApi api)
    Parameters
    Type Name Description
    System.String subsystemId

    The string name associated with the camera provider to extend.

    ICameraImageApi api

    The API to use to perform provider-specific calls.

    RegisterGetNativePtrHandler(String, Func<XRCameraSubsystem, IntPtr>)

    For internal use. Allows a camera provider to register for the GetNativePtr extension.

    Declaration
    public static void RegisterGetNativePtrHandler(string subsystemId, Func<XRCameraSubsystem, IntPtr> handler)
    Parameters
    Type Name Description
    System.String subsystemId

    The string name associated with the camera provider to extend.

    Func<XRCameraSubsystem, IntPtr> handler

    A method that returns an IntPtr associated with a XRCameraSubsystem.

    RegisterIsPermissionGrantedHandler(String, Func<XRCameraSubsystem, Boolean>)

    For internal use. Allows a camera provider to register for the IsPermissionGranted extension.

    Declaration
    public static void RegisterIsPermissionGrantedHandler(string subsystemId, Func<XRCameraSubsystem, bool> handler)
    Parameters
    Type Name Description
    System.String subsystemId

    The string name associated with the camera provider to extend.

    Func<XRCameraSubsystem, System.Boolean> handler

    A method that returns true if permission is granted.

    RegisterTryGetColorCorrectionHandler(String, XRCameraExtensions.TryGetColorCorrectionDelegate)

    For internal use. Allows a camera provider to register for the TryGetColorCorrection extension.

    Declaration
    public static void RegisterTryGetColorCorrectionHandler(string subsystemId, XRCameraExtensions.TryGetColorCorrectionDelegate handler)
    Parameters
    Type Name Description
    System.String subsystemId

    The string name associated with the camera provider to extend.

    XRCameraExtensions.TryGetColorCorrectionDelegate handler

    A method that returns true if color correction is available.

    RegisterTryGetIntrinsicsHandler(String, XRCameraExtensions.TryGetIntrinsicsDelegate)

    Allows a camera provider to register support for TryGetIntrinsics(XRCameraSubsystem, out CameraIntrinsics). This is typically only used by platform-specific packages.

    Declaration
    public static void RegisterTryGetIntrinsicsHandler(string subsystemId, XRCameraExtensions.TryGetIntrinsicsDelegate handler)
    Parameters
    Type Name Description
    System.String subsystemId

    The string name associated with the camera provider to extend.

    XRCameraExtensions.TryGetIntrinsicsDelegate handler

    A method to get the camera intriniscs that should return true when successful, or false otherwise.

    RegisterTrySetFocusModeHandler(String, Func<XRCameraSubsystem, CameraFocusMode, Boolean>)

    Allows a camera provider to register support for TrySetFocusMode(XRCameraSubsystem, CameraFocusMode). This is typically only used by platform-specific packages.

    Declaration
    public static void RegisterTrySetFocusModeHandler(string subsystemId, Func<XRCameraSubsystem, CameraFocusMode, bool> handler)
    Parameters
    Type Name Description
    System.String subsystemId

    The string name associated with the camera provider to extend.

    Func<XRCameraSubsystem, CameraFocusMode, System.Boolean> handler

    A method to set whether auto focus is enabled and returns true is successful, or false otherwise.

    SetCurrentConfiguration(XRCameraSubsystem, CameraConfiguration)

    Set a CameraConfiguration to be the active one. Throws if the camera configuration is not supported by the device. You can enumerate the available configurations with Configurations(XRCameraSubsystem).

    The camera image configuration affects the resolution of the CameraImage provided by TryGetLatestImage(XRCameraSubsystem, out CameraImage). It may also affect the camera framerate. See framerate.

    Setting this value may cause the device to relocalize, similar to stopping and restarting the session.

    All CameraImages should be disposed and all asynchronous conversion operations completed prior to setting the configuration or the this method may throw InvalidOperationException, depending on the platform.

    Declaration
    public static void SetCurrentConfiguration(this XRCameraSubsystem cameraSubsystem, CameraConfiguration configuration)
    Parameters
    Type Name Description
    XRCameraSubsystem cameraSubsystem

    The XRCameraSubsystem being extended.

    CameraConfiguration configuration

    A configuration to use. This is typically one of the configurations returned by .

    TryGetColorCorrection(XRCameraSubsystem, out Color)

    Attempts to retrieve color correction data for the extended XRCameraSubsystem. The color correction data represents the scaling factors used for color correction. The RGB scale factors are used to match the color of the light in the scene. The alpha channel value is platform-specific.

    Declaration
    public static bool TryGetColorCorrection(this XRCameraSubsystem cameraSubsystem, out Color color)
    Parameters
    Type Name Description
    XRCameraSubsystem cameraSubsystem

    The XRCameraSubsystem being extended.

    Color color

    The Color representing the color correction value.

    Returns
    Type Description
    System.Boolean

    True if the data is available, otherwise False.

    TryGetIntrinsics(XRCameraSubsystem, out CameraIntrinsics)

    Attempt to get the hardware camera's intrinsics. Intrinsics describe physical characteristics of a camera, which may be necessary to perform computer vision algorithms or other processing.

    Declaration
    public static bool TryGetIntrinsics(this XRCameraSubsystem cameraSubsystem, out CameraIntrinsics cameraIntrinsics)
    Parameters
    Type Name Description
    XRCameraSubsystem cameraSubsystem

    The XRCameraSubsystem being extended.

    CameraIntrinsics cameraIntrinsics

    If this method returns true, this parameter will be populated with intrinsics describing the physical camera.

    Returns
    Type Description
    System.Boolean

    true if successful, otherwise false.

    TryGetLatestImage(XRCameraSubsystem, out CameraImage)

    Attempt to get the latest camera image. This provides directly access to the raw pixel data, as well as utilities to convert to RGB and Grayscale formats. The CameraImage must be disposed to avoid resource leaks.

    Declaration
    public static bool TryGetLatestImage(this XRCameraSubsystem cameraSubsystem, out CameraImage cameraImage)
    Parameters
    Type Name Description
    XRCameraSubsystem cameraSubsystem

    The XRCameraSubsystem being extended.

    CameraImage cameraImage

    A valid CameraImage if this method returns true.

    Returns
    Type Description
    System.Boolean

    true if the image was acquired; false otherwise.

    TrySetFocusMode(XRCameraSubsystem, CameraFocusMode)

    Attempt to set the CameraFocusMode.

    Declaration
    public static bool TrySetFocusMode(this XRCameraSubsystem cameraSubsystem, CameraFocusMode mode)
    Parameters
    Type Name Description
    XRCameraSubsystem cameraSubsystem

    The XRCameraSubsystem being extended.

    CameraFocusMode mode

    The CameraFocusMode to use.

    Returns
    Type Description
    System.Boolean

    true if the focus mode was successfully set; false otherwise.

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023