Class XRCameraSubsystem | AR Subsystems | 3.1.10
docs.unity3d.com
    Show / Hide Table of Contents

    Class XRCameraSubsystem

    Provides access to a device's camera.

    Inheritance
    Object
    Subsystem
    Subsystem<XRCameraSubsystemDescriptor>
    XRSubsystem<XRCameraSubsystemDescriptor>
    XRCameraSubsystem
    XRCameraSubsystemImpl
    Inherited Members
    XRSubsystem<XRCameraSubsystemDescriptor>.running
    XRSubsystem<XRCameraSubsystemDescriptor>.Destroy()
    XRSubsystem<XRCameraSubsystemDescriptor>.Start()
    XRSubsystem<XRCameraSubsystemDescriptor>.Stop()
    Subsystem<XRCameraSubsystemDescriptor>.SubsystemDescriptor
    Subsystem.OnDestroy()
    Namespace: UnityEngine.XR.ARSubsystems
    Syntax
    public abstract class XRCameraSubsystem : XRSubsystem<XRCameraSubsystemDescriptor>, ISubsystem
    Remarks

    The XRCameraSubsystem links a Unity Camera to a device camera for video overlay (pass-thru rendering). It also allows developers to query for environmental light estimation, when available.

    Constructors

    XRCameraSubsystem()

    Construct the XRCameraSubsystem.

    Declaration
    public XRCameraSubsystem()

    Properties

    cameraMaterial

    Get the material used by XRCameraSubsystem to render the camera texture.

    Declaration
    public Material cameraMaterial { get; }
    Property Value
    Type Description
    Material

    The material to render the camera texture.

    currentConfiguration

    The current camera configuration.

    Declaration
    public virtual XRCameraConfiguration? currentConfiguration { get; set; }
    Property Value
    Type Description
    Nullable<XRCameraConfiguration>

    The current camera configuration if it exists. Otherise, null.

    Exceptions
    Type Condition
    NotSupportedException

    Thrown when setting the current configuration if the implementation does not support camera configurations.

    ArgumentNullException

    Thrown when setting the current configuration if the given configuration is null.

    ArgumentException

    Thrown when setting the current configuration if the given configuration is not a supported camera configuration.

    InvalidOperationException

    Thrown when setting the current configuration if the implementation is unable to set the current camera configuration.

    focusMode

    Get or set the focus mode for the camera.

    Declaration
    public CameraFocusMode focusMode { get; set; }
    Property Value
    Type Description
    CameraFocusMode

    The focus mode for the camera.

    invertCulling

    Whether to invert the culling mode during rendering. Some front-facing camera modes may require this.

    Declaration
    public bool invertCulling { get; }
    Property Value
    Type Description
    Boolean

    lightEstimationMode

    Specifies the light estimation mode.

    Declaration
    public LightEstimationMode lightEstimationMode { get; set; }
    Property Value
    Type Description
    LightEstimationMode

    The light estimation mode.

    permissionGranted

    Determines whether camera permission has been granted.

    Declaration
    public bool permissionGranted { get; }
    Property Value
    Type Description
    Boolean

    true if camera permission has been granted. Otherwise, false.

    Methods

    CreateProvider()

    Method for the implementation to create the camera functionality provider.

    Declaration
    protected abstract XRCameraSubsystem.Provider CreateProvider()
    Returns
    Type Description
    XRCameraSubsystem.Provider

    The camera functionality provider.

    GetConfigurations(Allocator)

    Queries for the supported camera configurations.

    Declaration
    public NativeArray<XRCameraConfiguration> GetConfigurations(Allocator allocator)
    Parameters
    Type Name Description
    Allocator allocator

    The allocation strategy to use for the returned data.

    Returns
    Type Description
    NativeArray<XRCameraConfiguration>

    The supported camera configurations.

    GetMaterialKeywords(out List<String>, out List<String>)

    Get the enabled and disabled shader keywords for the material.

    Declaration
    public void GetMaterialKeywords(out List<string> enabledKeywords, out List<string> disabledKeywords)
    Parameters
    Type Name Description
    List<String> enabledKeywords

    The keywords to enable for the material.

    List<String> disabledKeywords

    The keywords to disable for the material.

    GetTextureDescriptors(Allocator)

    Gets the XRTextureDescriptors associated with the current frame. The caller owns the returned NativeArray and is responsible for calling Dispose on it.

    Declaration
    public NativeArray<XRTextureDescriptor> GetTextureDescriptors(Allocator allocator)
    Parameters
    Type Name Description
    Allocator allocator

    The allocator to use when creating the returned NativeArray.

    Returns
    Type Description
    NativeArray<XRTextureDescriptor>

    An array of texture descriptors.

    OnDestroyed()

    Destroy the camera subsystem.

    Declaration
    protected override sealed void OnDestroyed()
    Overrides
    UnityEngine.XR.ARSubsystems.XRSubsystem<UnityEngine.XR.ARSubsystems.XRCameraSubsystemDescriptor>.OnDestroyed()

    OnStart()

    Start the camera subsystem.

    Declaration
    protected override sealed void OnStart()
    Overrides
    UnityEngine.XR.ARSubsystems.XRSubsystem<UnityEngine.XR.ARSubsystems.XRCameraSubsystemDescriptor>.OnStart()

    OnStop()

    Stop the camera subsystem.

    Declaration
    protected override sealed void OnStop()
    Overrides
    UnityEngine.XR.ARSubsystems.XRSubsystem<UnityEngine.XR.ARSubsystems.XRCameraSubsystemDescriptor>.OnStop()

    Register(XRCameraSubsystemCinfo)

    Registers a camera subsystem implementation based on the given subsystem parameters.

    Declaration
    public static bool Register(XRCameraSubsystemCinfo cameraSubsystemParams)
    Parameters
    Type Name Description
    XRCameraSubsystemCinfo cameraSubsystemParams

    The parameters defining the camera subsystem functionality implemented by the subsystem provider.

    Returns
    Type Description
    Boolean

    true if the subsystem implementation is registered. Otherwise, false.

    Exceptions
    Type Condition
    ArgumentException

    Thrown when the values specified in the XRCameraSubsystemCinfo parameter are invalid. Typically, this will occur

    • if id is null or empty
    • if implementationType is null
    • if implementationType does not derive from the XRCameraSubsystem class

    TryGetIntrinsics(out XRCameraIntrinsics)

    Returns the camera intrinsics information.

    Declaration
    public bool TryGetIntrinsics(out XRCameraIntrinsics cameraIntrinsics)
    Parameters
    Type Name Description
    XRCameraIntrinsics cameraIntrinsics

    The camera intrinsics information returned from the method.

    Returns
    Type Description
    Boolean

    true if the method successfully gets the camera intrinsics information. Otherwise, false.

    TryGetLatestFrame(XRCameraParams, out XRCameraFrame)

    Get the latest frame from the provider.

    Declaration
    public bool TryGetLatestFrame(XRCameraParams cameraParams, out XRCameraFrame frame)
    Parameters
    Type Name Description
    XRCameraParams cameraParams

    The Unity Camera parameters.

    XRCameraFrame frame

    The camera frame to be populated if the subsystem is running and successfully provides the latest camera frame.

    Returns
    Type Description
    Boolean

    true if the camera frame is successfully returned. Otherwise, false.

    TryGetLatestImage(out XRCameraImage)

    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.

    Declaration
    public bool TryGetLatestImage(out XRCameraImage cameraImage)
    Parameters
    Type Name Description
    XRCameraImage cameraImage

    A valid XRCameraImage if this method returns true.

    Returns
    Type Description
    Boolean

    true if the image was acquired. Otherwise, false.

    Remarks

    The returned XRCameraImage must be disposed to avoid resource leaks.

    Exceptions
    Type Condition
    NotSupportedException

    Thrown if the implementation does not support camera image.

    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