Class ARBoundingBoxManager
A trackable manager that detects and tracks 3D bounding boxes in the physical environment. Add this component to your XROrigin GameObject to enable 3D bounding box detection in your app.
Inheritance
Implements
Inherited Members
Namespace: UnityEngine.XR.ARFoundation
Assembly: Unity.XR.ARFoundation.dll
Syntax
[DefaultExecutionOrder(-2147483647)]
[DisallowMultipleComponent]
[RequireComponent(typeof(XROrigin))]
public class ARBoundingBoxManager : ARTrackableManager<XRBoundingBoxSubsystem, XRBoundingBoxSubsystemDescriptor, XRBoundingBoxSubsystem.Provider, XRBoundingBox, ARBoundingBox>, ITrackablesChanged<ARBoundingBox>
Properties
boundingBoxPrefab
Get or set the prefab to instantiate for each detected 3D bounding box. Can be null.
Declaration
public GameObject boundingBoxPrefab { get; set; }
Property Value
| Type | Description |
|---|---|
| GameObject |
gameObjectName
The name to be used for the instantiated GameObject whenever a new 3D bounding box is detected.
Declaration
protected override string gameObjectName { get; }
Property Value
| Type | Description |
|---|---|
| string |
Overrides
Methods
Awake()
Saves a reference to the XR Origin component and initializes the BoundingBoxRaycaster.
Declaration
protected override void Awake()
Overrides
GetPrefab()
Get the prefab to instantiate for each detected 3D bounding box. Can be null.
Declaration
protected override GameObject GetPrefab()
Returns
| Type | Description |
|---|---|
| GameObject | The Prefab which will be instantiated for each ARBoundingBox. |
Overrides
OnDisable()
Invoked when this component is disabled. Used to unregister with the ARRaycastManager.
Declaration
protected override void OnDisable()
Overrides
OnEnable()
Invoked when Unity enables this MonoBehaviour. Used to register with the ARRaycastManager.
Declaration
protected override void OnEnable()
Overrides
Raycast(Ray, TrackableType, Allocator)
Performs a raycast against all currently tracked 3D bounding boxes.
Declaration
public NativeArray<XRRaycastHit> Raycast(Ray ray, TrackableType trackableTypeMask, Allocator allocator)
Parameters
| Type | Name | Description |
|---|---|---|
| Ray | ray | The ray, in Unity world space, to cast. |
| TrackableType | trackableTypeMask | A mask of raycast types to perform. |
| Allocator | allocator | The |
Returns
| Type | Description |
|---|---|
| NativeArray<XRRaycastHit> | A new |
TryGetBoundingBox(TrackableId, out ARBoundingBox)
Attempt to retrieve an existing ARBoundingBox by trackableId.
Declaration
public bool TryGetBoundingBox(TrackableId trackableId, out ARBoundingBox arBoundingBox)
Parameters
| Type | Name | Description |
|---|---|---|
| TrackableId | trackableId | The |
| ARBoundingBox | arBoundingBox | The output bounding box, if this method returns true. |
Returns
| Type | Description |
|---|---|
| bool | true if a bounding box exists with the given |