docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class XROcclusionSubsystem

    Defines an interface for interacting with occlusion functionality.

    Inheritance
    object
    SubsystemWithProvider
    SubsystemWithProvider<XROcclusionSubsystem, XROcclusionSubsystemDescriptor, XROcclusionSubsystem.Provider>
    XROcclusionSubsystem
    SimulationOcclusionSubsystem
    Implements
    ISubsystem
    Inherited Members
    SubsystemWithProvider<XROcclusionSubsystem, XROcclusionSubsystemDescriptor, XROcclusionSubsystem.Provider>.OnCreate()
    SubsystemWithProvider<XROcclusionSubsystem, XROcclusionSubsystemDescriptor, XROcclusionSubsystem.Provider>.OnStart()
    SubsystemWithProvider<XROcclusionSubsystem, XROcclusionSubsystemDescriptor, XROcclusionSubsystem.Provider>.OnStop()
    SubsystemWithProvider<XROcclusionSubsystem, XROcclusionSubsystemDescriptor, XROcclusionSubsystem.Provider>.OnDestroy()
    SubsystemWithProvider<XROcclusionSubsystem, XROcclusionSubsystemDescriptor, XROcclusionSubsystem.Provider>.subsystemDescriptor
    SubsystemWithProvider<XROcclusionSubsystem, XROcclusionSubsystemDescriptor, XROcclusionSubsystem.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 XROcclusionSubsystem : SubsystemWithProvider<XROcclusionSubsystem, XROcclusionSubsystemDescriptor, XROcclusionSubsystem.Provider>, ISubsystem

    Constructors

    XROcclusionSubsystem()

    Construct the subsystem by creating the functionality provider.

    Declaration
    public XROcclusionSubsystem()

    Properties

    currentEnvironmentDepthMode

    Get the environment depth mode currently in use by the provider.

    Declaration
    public EnvironmentDepthMode currentEnvironmentDepthMode { get; }
    Property Value
    Type Description
    EnvironmentDepthMode

    currentHumanDepthMode

    Get the human segmentation depth mode currently in use by the provider.

    Declaration
    public HumanSegmentationDepthMode currentHumanDepthMode { get; }
    Property Value
    Type Description
    HumanSegmentationDepthMode

    currentHumanStencilMode

    Get the current segmentation stencil mode in use by the subsystem.

    Declaration
    public HumanSegmentationStencilMode currentHumanStencilMode { get; }
    Property Value
    Type Description
    HumanSegmentationStencilMode

    currentOcclusionPreferenceMode

    Get the occlusion preference mode currently in use by the provider.

    Declaration
    public OcclusionPreferenceMode currentOcclusionPreferenceMode { get; }
    Property Value
    Type Description
    OcclusionPreferenceMode

    The current occlusion preference mode.

    environmentDepthTemporalSmoothingEnabled

    Get whether temporal smoothing is applied to the environment depth image. Query for support with environmentDepthTemporalSmoothingSupported.

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

    true if temporal smoothing is enabled for the environment depth image. Otherwise, false.

    environmentDepthTemporalSmoothingRequested

    Get or set whether temporal smoothing should be applied to the environment depth image. Query for support with environmentDepthTemporalSmoothingSupported.

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

    true if temporal smoothing is requested for the environment depth image. Otherwise, false.

    requestedEnvironmentDepthMode

    Specifies the environment depth mode.

    Declaration
    public EnvironmentDepthMode requestedEnvironmentDepthMode { get; set; }
    Property Value
    Type Description
    EnvironmentDepthMode

    The environment depth mode.

    requestedHumanDepthMode

    Specifies the human segmentation depth mode.

    Declaration
    public HumanSegmentationDepthMode requestedHumanDepthMode { get; set; }
    Property Value
    Type Description
    HumanSegmentationDepthMode

    The human segmentation depth mode.

    Exceptions
    Type Condition
    NotSupportedException

    Thrown when setting the human segmentation depth mode to enabled if the implementation does not support human segmentation.

    requestedHumanStencilMode

    Specifies the human segmentation stencil mode.

    Declaration
    public HumanSegmentationStencilMode requestedHumanStencilMode { get; set; }
    Property Value
    Type Description
    HumanSegmentationStencilMode

    The human segmentation stencil mode.

    Exceptions
    Type Condition
    NotSupportedException

    Thrown when setting the human segmentation stencil mode to enabled if the implementation does not support human segmentation.

    requestedOcclusionPreferenceMode

    Specifies the requested occlusion preference mode.

    Declaration
    public OcclusionPreferenceMode requestedOcclusionPreferenceMode { get; set; }
    Property Value
    Type Description
    OcclusionPreferenceMode

    The requested occlusion preference mode.

    Methods

    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
    [Obsolete("GetShaderKeywords is deprecated as of AR Foundation 6.1. Use GetShaderKeywords2 instead.")]
    public ShaderKeywords GetShaderKeywords()
    Returns
    Type Description
    ShaderKeywords

    Returns an ShaderKeywords with the enabled and disabled shader keywords for the Material.

    GetShaderKeywords2()

    Get the shader keywords that are enabled or disabled by the provider.

    Declaration
    public XRShaderKeywords GetShaderKeywords2()
    Returns
    Type Description
    XRShaderKeywords

    The enabled and disabled shader keywords.

    GetTextureDescriptors(Allocator)

    Gets the occlusion texture descriptors associated with the current AR frame.

    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.

    Remarks

    The caller owns the returned NativeArray and is responsible for calling Dispose on it.

    Register(XROcclusionSubsystemCinfo)

    Register the descriptor for the occlusion subsystem implementation.

    Declaration
    [Obsolete("XROcclusionSubsystem.Register(XROcclusionSubsystemCinfo) has been deprecated in AR Foundation version 6.0. Use XROcclusionSubsystemDescriptor.Register(XROcclusionSubsystemDescriptor.Cinfo) instead.")]
    public static bool Register(XROcclusionSubsystemCinfo occlusionSubsystemCinfo)
    Parameters
    Type Name Description
    XROcclusionSubsystemCinfo occlusionSubsystemCinfo

    The occlusion subsystem implementation construction information.

    Returns
    Type Description
    bool

    true if the descriptor was registered. Otherwise, false.

    TryAcquireEnvironmentDepthConfidenceCpuImage(out XRCpuImage)

    Tries to acquire the latest environment depth confidence CPU image.

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

    An acquired XRCpuImage, if this method returns true. The CPU image must be disposed by the caller.

    Returns
    Type Description
    bool

    true if the image was successfully acquired. Otherwise, false.

    TryAcquireEnvironmentDepthCpuImage(out XRCpuImage)

    Tries to acquire the latest environment depth CPU image.

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

    An acquired XRCpuImage, if this method returns true. The CPU image must be disposed by the caller.

    Returns
    Type Description
    bool

    true if an image was successfully acquired. Otherwise, false.

    Remarks

    Whether the depth image is smoothed or raw depends on the value of environmentDepthTemporalSmoothingEnabled.

    See Also
    environmentDepthTemporalSmoothingEnabled
    environmentDepthTemporalSmoothingRequested

    TryAcquireHumanDepthCpuImage(out XRCpuImage)

    Tries to acquire the latest human depth CPU image.

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

    An acquired XRCpuImage, if this method returns true. The CPU image must be disposed by the caller.

    Returns
    Type Description
    bool

    true if an image was successfully acquired. Otherwise, false.

    TryAcquireHumanStencilCpuImage(out XRCpuImage)

    Tries to acquire the latest human stencil CPU image.

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

    An acquired XRCpuImage, if this method returns true. The CPU image must be disposed by the caller.

    Returns
    Type Description
    bool

    true if an image was successfully acquired. Otherwise, false.

    TryAcquireRawEnvironmentDepthCpuImage(out XRCpuImage)

    Tries to acquire the latest raw environment depth CPU image.

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

    An acquired XRCpuImage, if this method returns true. The CPU image must be disposed by the caller.

    Returns
    Type Description
    bool

    true if the raw environment depth CPU image was acquired. Otherwise, false.

    Remarks

    This method differs from TryAcquireEnvironmentDepthCpuImage(out XRCpuImage) in that it always tries to acquire the raw depth image, whereas the image provided by TryAcquireEnvironmentDepthCpuImage(out XRCpuImage) depends on the value of environmentDepthTemporalSmoothingEnabled.

    TryAcquireSmoothedEnvironmentDepthCpuImage(out XRCpuImage)

    Tries to acquire the latest smoothed environment depth CPU image.

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

    An acquired XRCpuImage, if this method returns true. The CPU image must be disposed by the caller.

    Returns
    Type Description
    bool

    true if the smoothed environment depth CPU image was acquired. Otherwise, false.

    Remarks

    This method differs from TryAcquireEnvironmentDepthCpuImage(out XRCpuImage) in that it always tries to acquire the temporally smoothed depth image, whereas the image provided by TryAcquireEnvironmentDepthCpuImage(out XRCpuImage) depends on the value of environmentDepthTemporalSmoothingEnabled.

    The type of smoothing applied is implementation dependent; refer to the documentation for the specific provider in use.

    TryGetEnvironmentDepth(out XRTextureDescriptor)

    Gets the environment depth texture descriptor.

    Declaration
    public bool TryGetEnvironmentDepth(out XRTextureDescriptor environmentDepthDescriptor)
    Parameters
    Type Name Description
    XRTextureDescriptor environmentDepthDescriptor

    The environment depth texture descriptor to be populated, if available from the provider.

    Returns
    Type Description
    bool

    true if the environment depth texture descriptor is available and returned. Otherwise, false.

    Remarks

    Whether the depth image is smoothed or raw depends on the value of environmentDepthTemporalSmoothingEnabled.

    Exceptions
    Type Condition
    NotSupportedException

    Thrown if the implementation does not support environment depth texture.

    TryGetEnvironmentDepthConfidence(out XRTextureDescriptor)

    Gets the environment depth confidence texture descriptor.

    Declaration
    public bool TryGetEnvironmentDepthConfidence(out XRTextureDescriptor environmentDepthConfidenceDescriptor)
    Parameters
    Type Name Description
    XRTextureDescriptor environmentDepthConfidenceDescriptor

    The environment depth confidence texture descriptor to be populated, if available from the provider.

    Returns
    Type Description
    bool

    true if the environment depth confidence texture descriptor is available and returned. Otherwise, false.

    Exceptions
    Type Condition
    NotSupportedException

    Thrown if the implementation does not support environment depth confidence texture.

    TryGetFrame(Allocator, out XROcclusionFrame)

    Get the current occlusion frame.

    Declaration
    public bool TryGetFrame(Allocator allocator, out XROcclusionFrame frame)
    Parameters
    Type Name Description
    Allocator allocator

    The allocator to use for any NativeArray_1s contained in the frame.

    XROcclusionFrame frame

    The output occlusion frame, if this method returned true.

    Returns
    Type Description
    bool

    true if the method successfully got a frame. Otherwise, false.

    TryGetHumanDepth(out XRTextureDescriptor)

    Gets the human depth texture descriptor.

    Declaration
    public bool TryGetHumanDepth(out XRTextureDescriptor humanDepthDescriptor)
    Parameters
    Type Name Description
    XRTextureDescriptor humanDepthDescriptor

    The human depth texture descriptor to be populated, if available from the provider.

    Returns
    Type Description
    bool

    true if the human depth texture descriptor is available and returned. Otherwise, false.

    Exceptions
    Type Condition
    NotSupportedException

    Thrown if the implementation does not support human depth texture.

    TryGetHumanStencil(out XRTextureDescriptor)

    Gets the human stencil texture descriptor.

    Declaration
    public bool TryGetHumanStencil(out XRTextureDescriptor humanStencilDescriptor)
    Parameters
    Type Name Description
    XRTextureDescriptor humanStencilDescriptor

    The human stencil texture descriptor to be populated, if available from the provider.

    Returns
    Type Description
    bool

    true if the human stencil texture descriptor is available and returned. Otherwise, false.

    Exceptions
    Type Condition
    NotSupportedException

    Thrown if the implementation does not support human stencil texture.

    TryGetSwapchainTextureDescriptors(out NativeArray<NativeArray<XRTextureDescriptor>>)

    Get all the texture descriptors in the provider's swapchain, if possible. Must return false if the provider does not use a fixed-length swapchain.

    Declaration
    public bool TryGetSwapchainTextureDescriptors(out NativeArray<NativeArray<XRTextureDescriptor>> swapchainDescriptors)
    Parameters
    Type Name Description
    NativeArray<NativeArray<XRTextureDescriptor>> swapchainDescriptors

    All texture descriptors in the provider's swapchain, if this method returns true. Each texture descriptor represents a possible value used by call to GetTextureDescriptors(Allocator) on a later frame. Allocator is Allocator.Temp.

     Texture descriptors are grouped per frame. All texture descriptors that are used within one frame must
     be grouped together in the same inner array.
    
    Returns
    Type Description
    bool

    true if the provider uses a fixed-length swapchain and all texture descriptors were successfully output. Otherwise, false.

    Remarks

    This method is used by the AR Occlusion Manager component during OnBeforeStart to determine whether the provider uses a fixed-length swapchain of fixed-size textures. If so, AROcclusionManager is able to create Unity Texture objects for the entire swapchain at once and re-use them throughout the life cycle of your app.

    See Also
    GetTextureDescriptors(Allocator)

    Implements

    ISubsystem
    In This Article
    Back to top
    Copyright © 2025 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)