Class ARAnchorManager
Manages anchors.
Inheritance
Inherited Members
Namespace: UnityEngine.XR.ARFoundation
Syntax
[DefaultExecutionOrder(-2147483647)]
[DisallowMultipleComponent]
[RequireComponent(typeof(ARSessionOrigin))]
[HelpURL("https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@3.0/api/UnityEngine.XR.ARFoundation.ARAnchorManager.html")]
public sealed class ARAnchorManager : ARTrackableManager<XRAnchorSubsystem, XRAnchorSubsystemDescriptor, XRAnchor, ARAnchor>
Remarks
Use this component to programmatically add, remove, or query for
anchors. Anchors are Pose
s in the world
which will be periodically updated by an AR device as its understanding
of the world changes.
Subscribe to changes (added, updated, and removed) via the anchorsChanged event.
Properties
anchorPrefab
Getter/setter for the Anchor Prefab.
Declaration
public GameObject anchorPrefab { get; set; }
Property Value
Type | Description |
---|---|
GameObject |
gameObjectName
Declaration
protected override string gameObjectName { get; }
Property Value
Type | Description |
---|---|
String |
Overrides
Methods
AddAnchor(Pose)
Attempts to add an ARAnchor with the given Pose
.
Declaration
public ARAnchor AddAnchor(Pose pose)
Parameters
Type | Name | Description |
---|---|---|
Pose | pose | The pose, in Unity world space, of the ARAnchor. |
Returns
Type | Description |
---|---|
ARAnchor | A new ARAnchor if successful, otherwise |
Remarks
If GameObject
will be created. In either case, the resulting
GameObject
will have an ARAnchor component on it.
AttachAnchor(ARPlane, Pose)
Attempts to create a new anchor that is attached to an existing ARPlane.
Declaration
public ARAnchor AttachAnchor(ARPlane plane, Pose pose)
Parameters
Type | Name | Description |
---|---|---|
ARPlane | plane | The ARPlane to which to attach. |
Pose | pose | The initial |
Returns
Type | Description |
---|---|
ARAnchor | A new ARAnchor if successful, otherwise |
GetAnchor(TrackableId)
Gets the ARAnchor with given trackableId
,
or null
if it does not exist.
Declaration
public ARAnchor GetAnchor(TrackableId trackableId)
Parameters
Type | Name | Description |
---|---|---|
TrackableId | trackableId | The |
Returns
Type | Description |
---|---|
ARAnchor | The ARAnchor with |
GetPrefab()
Declaration
protected override GameObject GetPrefab()
Returns
Type | Description |
---|---|
GameObject |
Overrides
OnTrackablesChanged(List<ARAnchor>, List<ARAnchor>, List<ARAnchor>)
Declaration
protected override void OnTrackablesChanged(List<ARAnchor> addedPoints, List<ARAnchor> updatedPoints, List<ARAnchor> removedPoints)
Parameters
Type | Name | Description |
---|---|---|
List<ARAnchor> | addedPoints | |
List<ARAnchor> | updatedPoints | |
List<ARAnchor> | removedPoints |
Overrides
RemoveAnchor(ARAnchor)
Attempts to remove an ARAnchor.
Declaration
public bool RemoveAnchor(ARAnchor anchor)
Parameters
Type | Name | Description |
---|---|---|
ARAnchor | anchor | The anchor you wish to remove. |
Returns
Type | Description |
---|---|
Boolean |
|
Events
anchorsChanged
Invoked once per frame to communicate changes to anchors, including new anchors, the update of existing anchors, and the removal of previously existing anchors.
Declaration
public event Action<ARAnchorsChangedEventArgs> anchorsChanged
Event Type
Type | Description |
---|---|
Action<ARAnchorsChangedEventArgs> |