Class XRCameraSubsystem.Provider
Interface for providing camera functionality for the implementation.
Inherited Members
Namespace: UnityEngine.XR.ARSubsystems
Assembly: Unity.XR.ARSubsystems.dll
Syntax
public class XRCameraSubsystem.Provider : SubsystemProvider<XRCameraSubsystem>
Properties
autoFocusEnabled
Get whether auto focus is enabled.
Declaration
public virtual bool autoFocusEnabled { get; }
Property Value
Type | Description |
---|---|
bool |
See Also
autoFocusRequested
Get or set whether auto focus is requested.
Declaration
public virtual bool autoFocusRequested { get; set; }
Property Value
Type | Description |
---|---|
bool |
cameraMaterial
Get the Material used by this XRCameraSubsystem to render the camera texture.
Declaration
public virtual Material cameraMaterial { get; }
Property Value
Type | Description |
---|---|
Material | The Material to render the camera texture. |
cpuImageApi
An instance of the XRCpuImage.Api used to operate on XRCpuImage objects.
Declaration
public virtual XRCpuImage.Api cpuImageApi { get; }
Property Value
Type | Description |
---|---|
XRCpuImage.Api |
currentBackgroundRenderingMode
Get the current XRCameraBackgroundRenderingMode.
Declaration
public virtual XRCameraBackgroundRenderingMode currentBackgroundRenderingMode { get; }
Property Value
Type | Description |
---|---|
XRCameraBackgroundRenderingMode | The current XRCameraBackgroundRenderingMode. |
See Also
currentCamera
Get the actual camera facing direction.
Declaration
public virtual Feature currentCamera { get; }
Property Value
Type | Description |
---|---|
Feature | The current camera facing direction. |
See Also
currentConfiguration
Property to be implemented by the provider to query or set 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. |
ArgumentException | Thrown when setting the current configuration if the given configuration is not a valid, 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 subsystem.
Declaration
public virtual Feature currentLightEstimation { get; }
Property Value
Type | Description |
---|---|
Feature | The current light estimation mode. |
See Also
invertCulling
Get whether culling should be inverted during rendering. Some front-facing camera modes might require this.
Declaration
public virtual bool invertCulling { get; }
Property Value
Type | Description |
---|---|
bool | true if culling should be inverted during rendering. Otherwise, false. |
permissionGranted
Get whether camera permission has been granted.
Declaration
public virtual bool permissionGranted { get; }
Property Value
Type | Description |
---|---|
bool | true if camera permission has been granted. Otherwise, false. |
requestedBackgroundRenderingMode
Get or set the requested XRCameraBackgroundRenderingMode.
Declaration
public virtual XRSupportedCameraBackgroundRenderingMode requestedBackgroundRenderingMode { get; set; }
Property Value
Type | Description |
---|---|
XRSupportedCameraBackgroundRenderingMode | The requested background rendering mode. |
requestedCamera
Get or set the requested camera facing direction, that is, the AnyCamera bits.
Declaration
public virtual Feature requestedCamera { get; set; }
Property Value
Type | Description |
---|---|
Feature | The requested camera facing direction |
requestedLightEstimation
Get or set the requested light estimation mode.
Declaration
public virtual Feature requestedLightEstimation { get; set; }
Property Value
Type | Description |
---|---|
Feature | The requested light estimation mode. |
supportedBackgroundRenderingMode
Get the supported XRCameraBackgroundRenderingModes defined as XRSupportedCameraBackgroundRenderingModes.
Declaration
public virtual XRSupportedCameraBackgroundRenderingMode supportedBackgroundRenderingMode { get; }
Property Value
Type | Description |
---|---|
XRSupportedCameraBackgroundRenderingMode | The supported background rendering modes. |
Methods
CreateCameraMaterial(string)
Create the camera material from the given camera shader name.
Declaration
protected Material CreateCameraMaterial(string cameraShaderName)
Parameters
Type | Name | Description |
---|---|---|
string | cameraShaderName | The name of the camera shader. |
Returns
Type | Description |
---|---|
Material | The created camera material shader. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown if the shader cannot be found or if a material cannot be created for the shader. |
Destroy()
Destroy the camera for the subsystem.
Declaration
public override void Destroy()
Overrides
GetConfigurations(XRCameraConfiguration, Allocator)
Get the supported camera configurations.
Declaration
public virtual NativeArray<XRCameraConfiguration> GetConfigurations(XRCameraConfiguration defaultCameraConfiguration, Allocator allocator)
Parameters
Type | Name | Description |
---|---|---|
XRCameraConfiguration | defaultCameraConfiguration | A default value used to fill the returned array before copying in real values. This ensures future additions to this struct are backwards compatible. |
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 virtual 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(XRTextureDescriptor, Allocator)
Get the XRTextureDescriptors associated with the current XRCameraFrame.
Declaration
public virtual NativeArray<XRTextureDescriptor> GetTextureDescriptors(XRTextureDescriptor defaultDescriptor, Allocator allocator)
Parameters
Type | Name | Description |
---|---|---|
XRTextureDescriptor | defaultDescriptor | A default value used to fill the returned array before copying in real values. This ensures future additions to this struct are backwards compatible. |
Allocator | allocator | The allocation strategy to use for the returned data.. |
Returns
Type | Description |
---|---|
NativeArray<XRTextureDescriptor> | The current texture descriptors. |
OnBeforeBackgroundRender(int)
Method to be implemented by the provider 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 virtual void OnBeforeBackgroundRender(int id)
Parameters
Type | Name | Description |
---|---|---|
int | id | Platform-specific identifier. |
Start()
Start the camera for the subsystem.
Declaration
public override void Start()
Overrides
Stop()
Stop the camera for the subsystem.
Declaration
public override void Stop()
Overrides
TryAcquireLatestCpuImage(out Cinfo)
Get the latest native camera image.
Declaration
public virtual bool TryAcquireLatestCpuImage(out XRCpuImage.Cinfo cameraImageCinfo)
Parameters
Type | Name | Description |
---|---|---|
XRCpuImage.Cinfo | cameraImageCinfo | The metadata required to construct a XRCpuImage. |
Returns
Type | Description |
---|---|
bool |
Exceptions
Type | Condition |
---|---|
NotSupportedException | Thrown if the implementation does not support camera image. |
TryGetFrame(XRCameraParams, out XRCameraFrame)
Get the camera frame for the subsystem.
Declaration
public virtual bool TryGetFrame(XRCameraParams cameraParams, out XRCameraFrame cameraFrame)
Parameters
Type | Name | Description |
---|---|---|
XRCameraParams | cameraParams | The current Unity |
XRCameraFrame | cameraFrame | The current camera frame returned by the method. |
Returns
Type | Description |
---|---|
bool | true if the method successfully got a frame. Otherwise, false. |
TryGetIntrinsics(out XRCameraIntrinsics)
Get the camera intrinsics information.
Declaration
public virtual bool TryGetIntrinsics(out XRCameraIntrinsics cameraIntrinsics)
Parameters
Type | Name | Description |
---|---|---|
XRCameraIntrinsics | cameraIntrinsics | The camera intrinsics information returned from the method. |
Returns
Type | Description |
---|---|
bool | true if the method successfully gets the camera intrinsics information. Otherwise, false. |