docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class XRCameraSubsystem

    Provides access to a device's camera.

    Inheritance
    object
    SubsystemWithProvider
    SubsystemWithProvider<XRCameraSubsystem, XRCameraSubsystemDescriptor, XRCameraSubsystem.Provider>
    XRCameraSubsystem
    SimulationCameraSubsystem
    Implements
    ISubsystem
    Inherited Members
    SubsystemWithProvider<XRCameraSubsystem, XRCameraSubsystemDescriptor, XRCameraSubsystem.Provider>.OnCreate()
    SubsystemWithProvider<XRCameraSubsystem, XRCameraSubsystemDescriptor, XRCameraSubsystem.Provider>.OnStart()
    SubsystemWithProvider<XRCameraSubsystem, XRCameraSubsystemDescriptor, XRCameraSubsystem.Provider>.OnStop()
    SubsystemWithProvider<XRCameraSubsystem, XRCameraSubsystemDescriptor, XRCameraSubsystem.Provider>.OnDestroy()
    SubsystemWithProvider<XRCameraSubsystem, XRCameraSubsystemDescriptor, XRCameraSubsystem.Provider>.subsystemDescriptor
    SubsystemWithProvider<XRCameraSubsystem, XRCameraSubsystemDescriptor, XRCameraSubsystem.Provider>.provider
    SubsystemWithProvider.Start()
    SubsystemWithProvider.OnStart()
    SubsystemWithProvider.Stop()
    SubsystemWithProvider.OnStop()
    SubsystemWithProvider.Destroy()
    SubsystemWithProvider.OnDestroy()
    SubsystemWithProvider.running
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.XR.ARSubsystems
    Assembly: Unity.XR.ARSubsystems.dll
    Syntax
    public class XRCameraSubsystem : SubsystemWithProvider<XRCameraSubsystem, XRCameraSubsystemDescriptor, XRCameraSubsystem.Provider>, 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 if available.

    Constructors

    XRCameraSubsystem()

    Construct the XRCameraSubsystem.

    Declaration
    public XRCameraSubsystem()

    Properties

    autoFocusEnabled

    Indicates whether auto focus is enabled.

    Declaration
    public bool autoFocusEnabled { get; }
    Property Value
    Type Description
    bool

    true if auto focus is enabled. Otherwise, false.

    See Also
    autoFocusRequested

    autoFocusRequested

    Get or set whether autofocus is requested.

    Declaration
    public bool autoFocusRequested { get; set; }
    Property Value
    Type Description
    bool

    true if autofocus is requested. Otherwise, false.

    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.

    currentCamera

    Get the camera currently in use.

    Declaration
    public Feature currentCamera { get; }
    Property Value
    Type Description
    Feature

    The current camera.

    currentCameraBackgroundRenderingMode

    Get the current XRCameraBackgroundRenderingMode.

    Declaration
    public XRCameraBackgroundRenderingMode currentCameraBackgroundRenderingMode { get; }
    Property Value
    Type Description
    XRCameraBackgroundRenderingMode

    The current camera background rendering mode.

    See Also
    requestedCameraBackgroundRenderingMode

    currentConfiguration

    The current camera configuration.

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

    The current camera configuration, if it exists. Otherwise, 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.

    currentLightEstimation

    Get the current light estimation mode in use by the provider.

    Declaration
    public Feature currentLightEstimation { get; }
    Property Value
    Type Description
    Feature

    The current light estimation mode.

    See Also
    requestedLightEstimation

    imageStabilizationEnabled

    Indicate whether Image Stabilization is enabled.

    Declaration
    public bool imageStabilizationEnabled { get; }
    Property Value
    Type Description
    bool

    true if EIS is enabled. Otherwise, false.

    See Also
    imageStabilizationRequested

    imageStabilizationRequested

    Get or set whether Image Stabilization is requested.

    Declaration
    public bool imageStabilizationRequested { get; set; }
    Property Value
    Type Description
    bool

    true if EIS is requested. Otherwise, false.

    invertCulling

    Set this to true to invert the culling mode during rendering. Some front-facing camera modes might require this.

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

    permissionGranted

    Indicates whether camera permission has been granted.

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

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

    requestedCamera

    Get or set the requested camera (that is, the AnyCamera bits).

    Declaration
    public Feature requestedCamera { get; set; }
    Property Value
    Type Description
    Feature

    The requested camera.

    requestedCameraBackgroundRenderingMode

    Get or set the requested XRSupportedCameraBackgroundRenderingMode.

    Declaration
    public XRSupportedCameraBackgroundRenderingMode requestedCameraBackgroundRenderingMode { get; set; }
    Property Value
    Type Description
    XRSupportedCameraBackgroundRenderingMode

    The requested camera background rendering mode.

    requestedLightEstimation

    Get or set the requested light estimation mode.

    Declaration
    public Feature requestedLightEstimation { get; set; }
    Property Value
    Type Description
    Feature

    The requested light estimation mode.

    supportedCameraBackgroundRenderingMode

    Get the supported XRSupportedCameraBackgroundRenderingModes. Indicates which XRCameraBackgroundRenderingModes are supported.

    Declaration
    public XRSupportedCameraBackgroundRenderingMode supportedCameraBackgroundRenderingMode { get; }
    Property Value
    Type Description
    XRSupportedCameraBackgroundRenderingMode

    The supported camera background rendering modes.

    Methods

    GetConfigurations(Allocator)

    Get 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
    [Obsolete("GetMaterialKeywords(out List<string>, out List<string>) has been deprecated in AR Foundation version 6.0. Use GetShaderKeywords() instead.")]
    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.

    GetShaderKeywords()

    Get the enabled and disabled shader keywords for the material.

    Declaration
    public ShaderKeywords GetShaderKeywords()
    Returns
    Type Description
    ShaderKeywords

    Returns an ShaderKeywords with the enabled and disabled shader keywords 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.

    OnBeforeBackgroundRender(int)

    Method to be called on the render thread to handle any required platform-specific functionality immediately before rendering the camera background. This method will always be called on the render thread and should only be called by the code responsible for executing background rendering on mobile AR platforms.

    Declaration
    public void OnBeforeBackgroundRender(int id)
    Parameters
    Type Name Description
    int id

    Platform-specific identifier.

    Register(XRCameraSubsystemCinfo)

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

    Declaration
    [Obsolete("XRCameraSubsystem.Register(XRCameraSubsystemCinfo) has been deprecated in AR Foundation version 6.0. Use XRCameraSubsystemDescriptor.Register(XRCameraSubsystemDescriptor.Cinfo) instead.")]
    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
    bool

    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 happens when required parameters are null or empty or types that do not derive from the required base class.

    TryAcquireLatestCpuImage(out XRCpuImage)

    Attempts to acquire the latest camera image. This provides direct access to the raw pixel data, as well as to utilities to convert to RGB and Grayscale formats.

    Declaration
    public bool TryAcquireLatestCpuImage(out XRCpuImage cpuImage)
    Parameters
    Type Name Description
    XRCpuImage cpuImage

    A valid XRCpuImage if this method returns true.

    Returns
    Type Description
    bool

    true if the image was acquired. Otherwise, false.

    Remarks

    The returned XRCpuImage must be disposed to avoid resource leaks.

    Exceptions
    Type Condition
    NotSupportedException

    Thrown if the implementation does not support camera image.

    TryGetIntrinsics(out XRCameraIntrinsics)

    Get the camera intrinsics information.

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

    The returned camera intrinsics information.

    Returns
    Type Description
    bool

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

    Remarks
    Note

    The intrinsics may change each frame. You should call this each frame that you need intrinsics in order to ensure you are using the intrinsics for the current frame.

    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
    bool

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

    TryGetRenderingParameters(out XRCameraBackgroundRenderingParams)

    Attempts to get the platform specific rendering parameters for rendering the camera background texture.

    Declaration
    public bool TryGetRenderingParameters(out XRCameraBackgroundRenderingParams cameraBackgroundRenderingParameters)
    Parameters
    Type Name Description
    XRCameraBackgroundRenderingParams cameraBackgroundRenderingParameters

    The platform specific rendering parameters for rendering the camera background texture.

    Returns
    Type Description
    bool

    true if the platform provides specialized rendering parameters or false otherwise.

    Implements

    ISubsystem
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)