Class XRCameraSubsystem.Provider
Interface for providing camera functionality for the implementation.
Namespace: UnityEngine.XR.ARSubsystems
Syntax
public class Provider
Properties
autoFocusEnabled
Property to be implemented by the provider to get the current camera focus mode.
Declaration
public virtual bool autoFocusEnabled { get; }
Property Value
Type | Description |
---|---|
Boolean |
autoFocusRequested
Property to be implemented by the provider to get or set the focus mode for the camera.
Declaration
public virtual bool autoFocusRequested { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
cameraMaterial
Property to be implemented by the provder to get the material used by 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 |
currentCamera
This property should get the actual camera facing direction.
Declaration
public virtual Feature currentCamera { get; }
Property Value
Type | Description |
---|---|
Feature |
currentConfiguration
Property to be implemented by the provider to query/set 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, |
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
Property to be implemented by the provider to get the current light estimation mode in use.
Declaration
public virtual Feature currentLightEstimation { get; }
Property Value
Type | Description |
---|---|
Feature |
invertCulling
Whether or not culling should be inverted during rendering. Some front-facing camera modes may require this.
Declaration
public virtual bool invertCulling { get; }
Property Value
Type | Description |
---|---|
Boolean |
permissionGranted
Property to be implemented by the provider to determine whether camera permission has been granted.
Declaration
public virtual bool permissionGranted { get; }
Property Value
Type | Description |
---|---|
Boolean |
|
requestedCamera
This property should 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 |
requestedLightEstimation
Property to be implemented by the provider to get or set the light estimation mode.
Declaration
public virtual Feature requestedLightEstimation { get; set; }
Property Value
Type | Description |
---|---|
Feature |
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()
Method to be implemented by provider to destroy the camera for the subsystem.
Declaration
public virtual void Destroy()
GetConfigurations(XRCameraConfiguration, Allocator)
Method to be implemented by the provider to query 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>)
Method to be implemented by the provider to 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 which should be used to fill the returned array before copying in the real values. This ensures future additions to this struct are backwards compatible. |
Allocator | allocator | The allocator to use when creating
the returned |
Returns
Type | Description |
---|---|
NativeArray<XRTextureDescriptor> | The current texture descriptors. |
OnBeforeBackgroundRender(Int32)
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 |
---|---|---|
Int32 | id | Platform specific identifier. |
Start()
Method to be implemented by provider to start the camera for the subsystem.
Declaration
public virtual void Start()
Stop()
Method to be implemented by provider to stop the camera for the subsystem.
Declaration
public virtual void Stop()
TryAcquireLatestCpuImage(out XRCpuImage.Cinfo)
Method to be implemented by the provider to query for 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 |
---|---|
Boolean |
|
Exceptions
Type | Condition |
---|---|
NotSupportedException | Thrown if the implementation does not support camera image. |
TryGetFrame(XRCameraParams, out XRCameraFrame)
Method to be implemented by provider to 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 |
---|---|
Boolean |
|
TryGetIntrinsics(out XRCameraIntrinsics)
Method to be implemented by the provider to get the camera intrinisics 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 |
---|---|
Boolean |
|