Class ARReferencePointManager
Manages reference points (aka anchors).
Inheritance
Namespace: UnityEngine.XR.ARFoundation
Syntax
public sealed class ARReferencePointManager : MonoBehaviour
Remarks
Use this component to programmatically add, remove, or query for
reference points. Reference points are Pose
s in the world
which will be periodically updated by an AR devices as its understanding
of the world changes.
Properties
referencePointPrefab
Getter/setter for the Reference Point Prefab.
Declaration
public GameObject referencePointPrefab { get; set; }
Property Value
Type | Description |
---|---|
GameObject |
Methods
GetAllReferencePoints(List<ARReferencePoint>)
Get all currently tracked ARReferencePoints.
Declaration
public void GetAllReferencePoints(List<ARReferencePoint> referencePointsOut)
Parameters
Type | Name | Description |
---|---|---|
List<ARReferencePoint> | referencePointsOut | Replaces the contents with the current list of reference points. |
TryAddReferencePoint(Pose)
Attempts to add an ARReferencePoint with the given Pose
.
Declaration
public ARReferencePoint TryAddReferencePoint(Pose pose)
Parameters
Type | Name | Description |
---|---|---|
Pose | pose | The pose, in Unity world space, of the ARReferencePoint. |
Returns
Type | Description |
---|---|
ARReferencePoint | If successful, a new ARReferencePoint. Otherwise, |
Remarks
If referencePointPrefab is not null, a new instance will be created. Otherwise, a
new GameObject
will be created. In either case, this method ensures that the resulting
GameObject
has a ARReferencePoint component on it.
TryAddReferencePoint(Vector3, Quaternion)
Attempts to add an ARReferencePoint with the given position and rotation.
Declaration
public ARReferencePoint TryAddReferencePoint(Vector3 position, Quaternion rotation)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | position | The position, in Unity world space, of the ARReferencePoint. |
Quaternion | rotation | The rotation, in Unity world space, of the ARReferencePoint. |
Returns
Type | Description |
---|---|
ARReferencePoint | If successful, a new ARReferencePoint. Otherwise, |
Remarks
If referencePointPrefab is not null, a new instance will be created. Otherwise, a
new GameObject
will be created. In either case, this method ensures that the resulting
GameObject
has a ARReferencePoint component on it.
TryGetReferencePoint(TrackableId)
Attempts to retrieve an existing ARReferencePoint previously added with TryAddReferencePoint(Pose).
Declaration
public ARReferencePoint TryGetReferencePoint(TrackableId referencePointId)
Parameters
Type | Name | Description |
---|---|---|
TrackableId | referencePointId | The |
Returns
Type | Description |
---|---|
ARReferencePoint | The ARReferencePoint with |
TryRemoveReferencePoint(TrackableId)
Attempts to remove an ARReferencePoint by TrackableId
Declaration
public bool TryRemoveReferencePoint(TrackableId referencePointId)
Parameters
Type | Name | Description |
---|---|---|
TrackableId | referencePointId | The |
Returns
Type | Description |
---|---|
System.Boolean | True if the reference point was successfully removed. False usually means the reference point doesn't exist or isn't tracked by this manager. |
TryRemoveReferencePoint(ARReferencePoint)
Attempts to remove an ARReferencePoint.
Declaration
public bool TryRemoveReferencePoint(ARReferencePoint referencePoint)
Parameters
Type | Name | Description |
---|---|---|
ARReferencePoint | referencePoint | The reference point you wish to remove. |
Returns
Type | Description |
---|---|
System.Boolean | True if the reference point was successfully removed. False usually means the reference point doesn't exist or isn't tracked by this manager. |
Events
referencePointUpdated
Raised each time an ARReferencePoint is updated.
Declaration
public event Action<ARReferencePointUpdatedEventArgs> referencePointUpdated
Event Type
Type | Description |
---|---|
Action<ARReferencePointUpdatedEventArgs> |
Remarks
This can happen when the ARReferencePoint's Pose
changes, or
when its TrackingState
changes.