class ARPersistentAnchorManager
(Niantic.Lightship.AR.PersistentAnchors.ARPersistentAnchorManager)
Overview
Manages persistent anchors.
class ARPersistentAnchorManager: ARTrackableManager< XRPersistentAnchorSubsystem, XRPersistentAnchorSubsystemDescriptor, XRPersistentAnchorSubsystem.Provider, XRPersistentAnchor, ARPersistentAnchor > {
public:
// events
event arPersistentAnchorStateChanged();
// methods
bool GetVpsSessionId(out string vpsSessionId);
bool TryTrackAnchor(
ARPersistentAnchorPayload payload,
out ARPersistentAnchor arPersistentAnchor
);
void DestroyAnchor(ARPersistentAnchor arPersistentAnchor);
protected:
// fields
bool InterpolateAnchors = false;
override string gameObjectName => "Persistent Anchor";
// properties
bool ContinuousLocalizationEnabled;
bool TemporalFusionEnabled;
bool TransformUpdateSmoothingEnabled;
float CloudLocalizerInitialRequestsPerSecond;
float CloudLocalizerContinuousRequestsPerSecond;
uint CloudLocalizationTemporalFusionWindowSize;
bool DiagnosticsEnabled;
// methods
override GameObject GetPrefab();
override void OnEnable();
override void OnBeforeStart();
virtual void Start();
override void OnDisable();
override void OnDestroy();
override void OnTrackablesChanged(
List<ARPersistentAnchor> added,
List<ARPersistentAnchor> updated,
List<ARPersistentAnchor> removed
);
};
// direct descendants
class ARLocationManager;
Detailed Documentation
Manages persistent anchors.
Use this component to programmatically restore, remove, or query for persistent anchors. Persistent anchors are persistent Poses in the world that are generated by processed scans, and will be in the same real world location in future sessions. By placing virtual content relative to a Persistent Anchor, it can be restored to the same real world location in a future session.
This is a low level API to manage Persistent Anchors. For authoring virtual content in the Unity Editor, use the ARLocationManager and ARLocations instead.
Subscribe to changes (added, updated, and removed) via the ARPersistentAnchorManager.arPersistentAnchorStateChanged event.
See also:
ARTrackableManager<TSubsystem,TSubsystemDescriptor,TProvider,TSessionRelativeData,TTrackable>
Fields
gameObjectName
override string gameObjectName => "Persistent Anchor"
The name to assign to the GameObject
instantiated for each ARPersistentAnchor.
Events
arPersistentAnchorStateChanged
event arPersistentAnchorStateChanged()
Called when the state of an anchor has changed
Each invocation of this event contains a single Persistent Anchor that has had a state or pose change this frame. Query the arg's arPersistentAnchor's TrackingState to determine its new TrackingState. Query the arPersistentAnchor's PredictedPose to determine its new PredictedPose.
Methods
GetPrefab
override GameObject GetPrefab()
The prefab to use when creating an ARPersistentAnchor. If null, a new GameObject will be created.
OnTrackablesChanged
override void OnTrackablesChanged(
List<ARPersistentAnchor> added,
List<ARPersistentAnchor> updated,
List<ARPersistentAnchor> removed
)
Invoked when the base class detects trackable changes.
Parameters:
added
- The list of added anchors.
updated
- The list of updated anchors.
removed
- The list of removed anchors.
GetVpsSessionId
bool GetVpsSessionId(out string vpsSessionId)
Gets the vps session id (as 32 character hexidecimal upper-case string) A vps session is defined between first TryTrackAnchor and last DestroyAnchor for a given set of anchors
Parameters:
vpsSessionId
- The vps session id as 32 character hexidecimal upper-case string
Returns:
True If vps session id can be obtained False If no vps session is running
TryTrackAnchor
bool TryTrackAnchor(
ARPersistentAnchorPayload payload,
out ARPersistentAnchor arPersistentAnchor
)
Restores a Persistent Anchor from a Payload. The Anchor GameObject will be returned immediately, and children can be added to it, but a proper position and rotation not be applied until its TrackingState is Tracking.
Parameters:
payload
- The payload of the anchor to restore
arPersistentAnchor
- The ARPersistentAnchor that was created from the payload
Returns:
True If the anchor was successfully added for tracking. False The anchor cannot be added, it is either already added, or the payload is invalid
DestroyAnchor
void DestroyAnchor(ARPersistentAnchor arPersistentAnchor)
Destroys an anchor and stop tracking it.
Parameters:
arPersistentAnchor
- The anchor to destroy