Class ARPlaneManager
A trackable manager that detects and tracks flat surfaces in the physical environment. Add this component to your XR Origin GameObject to enable plane 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 sealed class ARPlaneManager : ARTrackableManager<XRPlaneSubsystem, XRPlaneSubsystemDescriptor, XRPlaneSubsystem.Provider, BoundedPlane, ARPlane>, ITrackablesChanged<ARPlane>
Properties
currentDetectionMode
Get the current plane detection mode in use by the subsystem.
Declaration
public PlaneDetectionMode currentDetectionMode { get; }
Property Value
Type | Description |
---|---|
PlaneDetectionMode |
gameObjectName
The name to be used for the instantiated GameObject whenever a new plane is detected.
Declaration
protected override string gameObjectName { get; }
Property Value
Type | Description |
---|---|
string |
Overrides
planePrefab
Get or set the prefab to instantiate for each detected plane. Can be null.
Declaration
public GameObject planePrefab { get; set; }
Property Value
Type | Description |
---|---|
GameObject |
requestedDetectionMode
Get or set the requested plane detection mode.
Declaration
public PlaneDetectionMode requestedDetectionMode { get; set; }
Property Value
Type | Description |
---|---|
PlaneDetectionMode |
Methods
GetPlane(TrackableId)
Attempt to retrieve an existing ARPlane by trackableId
.
Declaration
public ARPlane GetPlane(TrackableId trackableId)
Parameters
Type | Name | Description |
---|---|---|
TrackableId | trackableId | The TrackableId of the plane to retrieve. |
Returns
Type | Description |
---|---|
ARPlane | The ARPlane with |
GetPrefab()
Get the prefab to instantiate for each detected plane. Can be null.
Declaration
protected override GameObject GetPrefab()
Returns
Type | Description |
---|---|
GameObject | The Prefab which will be instantiated for each ARPlane. |
Overrides
OnAfterSetSessionRelativeData(ARPlane, BoundedPlane)
Invoked just after each ARPlane is updated.
Declaration
protected override void OnAfterSetSessionRelativeData(ARPlane plane, BoundedPlane sessionRelativeData)
Parameters
Type | Name | Description |
---|---|---|
ARPlane | plane | The ARPlane being updated. |
BoundedPlane | sessionRelativeData | The new data associated with the plane. All spatial data is is session-relative space. |
Overrides
OnBeforeStart()
Invoked just before Start
ing the plane subsystem. Used to set the subsystem's
requestedPlaneDetectionMode
.
Declaration
protected override void OnBeforeStart()
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
OnTrackablesChanged(List<ARPlane>, List<ARPlane>, List<ARPlane>)
Invoked when the base class detects trackable changes.
Declaration
[Obsolete("OnTrackablesChanged() has been deprecated in AR Foundation version 6.0.", false)]
protected override void OnTrackablesChanged(List<ARPlane> added, List<ARPlane> updated, List<ARPlane> removed)
Parameters
Type | Name | Description |
---|---|---|
List<ARPlane> | added | The list of added ARPlanes. |
List<ARPlane> | updated | The list of updated ARPlanes. |
List<ARPlane> | removed | The list of removed ARPlanes. |
Overrides
Raycast(Ray, TrackableType, Allocator)
Performs a raycast against all currently tracked planes.
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 |
See Also
Events
planesChanged
Invoked when planes have changed (been added, updated, or removed).
Declaration
[Obsolete("planesChanged has been deprecated in AR Foundation version 6.0. Use trackablesChanged instead.", false)]
public event Action<ARPlanesChangedEventArgs> planesChanged
Event Type
Type | Description |
---|---|
Action<ARPlanesChangedEventArgs> |