class ARPersistentAnchorManager
(Niantic.Lightship.AR.PersistentAnchors.ARPersistentAnchorManager)
Overview
Manages persistent anchors.
class ARPersistentAnchorManager: ARTrackableManager< XRPersistentAnchorSubsystem, XRPersistentAnchorSubsystemDescriptor, XRPersistentAnchorSubsystem.Provider, XRPersistentAnchor, ARPersistentAnchor > {
public:
// properties
float InterpolationTimeSeconds;
bool ContinuousLocalizationEnabled;
bool InterpolationEnabled;
bool TemporalFusionEnabled;
int JpegCompressionQuality;
bool TransformUpdateSmoothingEnabled;
float InitialServiceRequestIntervalSeconds;
float ContinuousServiceRequestIntervalSeconds;
bool DiagnosticsEnabled;
float DeviceMappingLocalizationRequestIntervalSeconds;
bool CloudLocalizationEnabled;
bool DeviceMappingLocalizationEnabled;
DeviceMappingType DeviceMappingType;
bool DeviceMapDownloadEnabled;
// events
event arPersistentAnchorStateChanged();
event DebugInfoUpdated();
// methods
async Task RestartSubsystemAsync();
IEnumerator RestartSubsystemAsyncCoroutine();
bool GetVpsSessionId(out string vpsSessionId);
bool TryCreateAnchor(
Pose anchorLocalPose,
out ARPersistentAnchor arPersistentAnchor
);
bool TryTrackAnchor(
ARPersistentAnchorPayload payload,
out ARPersistentAnchor arPersistentAnchor
);
void DestroyAnchor(ARPersistentAnchor arPersistentAnchor);
protected:
// fields
override string gameObjectName => "Persistent Anchor";
// 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.
Properties
InterpolationTimeSeconds
float InterpolationTimeSeconds
Number of seconds over which anchor interpolation occurs. Faster times will result in more noticeable movement.
.. note::
This is an experimental feature, and is subject to breaking changes or deprecation without notice
ContinuousLocalizationEnabled
bool ContinuousLocalizationEnabled
Whether to enable or disable continuous localization
InterpolationEnabled
bool InterpolationEnabled
Whether to enable or disable legacy MonoBehaviour driven interpolation It is recommended to use the native solution "TransformUpdateSmoothingEnabled" instead of this property
TemporalFusionEnabled
bool TemporalFusionEnabled
Whether to enable or disable temporal fusion. Fusion will average multiple localization results to provide a more stable localization.
JpegCompressionQuality
int JpegCompressionQuality
Defines the JPEG compression quality for localization images. This only applies to cloud localization. Lower compression qualities will result in less bandwidth usage It is recommended to keep this above 20 to avoid localization quality loss
TransformUpdateSmoothingEnabled
bool TransformUpdateSmoothingEnabled
Whether to enable or disable transform update smoothing
InitialServiceRequestIntervalSeconds
float InitialServiceRequestIntervalSeconds
Number of seconds between server requests for initial localization. 0 value means as many requests as possible.
ContinuousServiceRequestIntervalSeconds
float ContinuousServiceRequestIntervalSeconds
Number of seconds between server requests for continuous localization. 0 value means as many requests as possible.
DiagnosticsEnabled
bool DiagnosticsEnabled
Whether to enable or disable frame diagnostics Listen to the DebugInfoUpdated event to get the diagnostics data
DeviceMappingLocalizationRequestIntervalSeconds
float DeviceMappingLocalizationRequestIntervalSeconds
Defines the interval between localization requests for Device Mapping Localization. Set to 0 for processing every frame.
DeviceMappingLocalizationEnabled
bool DeviceMappingLocalizationEnabled
Enable Device Localization
.. note::
This is an experimental feature, and is subject to breaking changes or deprecation without notice
DeviceMappingType
DeviceMappingType DeviceMappingType
Enable Learned Features in Device Localization
.. note::
This is an experimental feature, and is subject to breaking changes or deprecation without notice
DeviceMapDownloadEnabled
bool DeviceMapDownloadEnabled
Whether to enable or disable map download for device localization The maps will be downloaded from our Cloud and will be based on GPS location
.. note::
This is an experimental feature, and is subject to breaking changes or deprecation without notice
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.
DebugInfoUpdated
event DebugInfoUpdated()
Called when debug info is available
Each invocation of this event contains a XRPersistentAnchorDebugInfo object that contains arrays of XRPersistentAnchorNetworkRequestStatus, XRPersistentAnchorLocalizationStatus, and XRPersistentAnchorFrameDiagnostics
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.
RestartSubsystemAsync
async Task RestartSubsystemAsync()
Asynchronously restarts the subsystem with the current configuration. This will remove all anchors and stop the subsystem before restarting it.
RestartSubsystemAsyncCoroutine
IEnumerator RestartSubsystemAsyncCoroutine()
Asynchronously restarts the subsystem with the current configuration. This will remove all anchors and stop the subsystem before restarting it.
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
TryCreateAnchor
bool TryCreateAnchor(
Pose anchorLocalPose,
out ARPersistentAnchor arPersistentAnchor
)
Creates Anchor from Pose
.. note::
This is an experimental feature, and is subject to breaking changes or deprecation without notice
Parameters:
anchorLocalPose
- The localToCamera of the anchor to create
arPersistentAnchor
- The ARPersistentAnchor that was created from the pose
Returns:
True If the anchor was successfully crated/added for tracking. False The anchor cannot be crated/added, it is either already crated/added
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