Skip to main content
Version: 3.6

class XRPersistentAnchorSubsystem

(Niantic.Lightship.AR.XRSubsystems.XRPersistentAnchorSubsystem)

Overview

Base class for a persistent anchor subsystem.

	class XRPersistentAnchorSubsystem: TrackingSubsystem< XRPersistentAnchor, XRPersistentAnchorSubsystem, XRPersistentAnchorSubsystemDescriptor, XRPersistentAnchorSubsystem.Provider > {
public:

class Provider;

// fields

bool IsMockProvider => provider.IsMockProvider;

// properties

XRPersistentAnchorConfiguration? CurrentConfiguration;

// events

event debugInfoProvided();
event OnConfigurationChanged();

// methods

XRPersistentAnchorSubsystem();
new void Start();
override TrackableChanges<XRPersistentAnchor> GetChanges(Allocator allocator);
bool TryAddAnchor(Pose pose, out XRPersistentAnchor anchor);
bool TryRemoveAnchor(TrackableId anchorId);

bool TryRestoreAnchor(
XRPersistentAnchorPayload anchorPayload,
out XRPersistentAnchor anchor
);

bool TryLocalize(
XRPersistentAnchorPayload anchorPayload,
out XRPersistentAnchor anchor
);

bool GetVpsSessionId(out string vpsSessionId);
bool TryAddMap(byte[] dataBytes);
bool TryAddGraph(byte[] dataBytes);

protected:
// methods

override void OnStart();
override void OnStop();
};

Detailed Documentation

Base class for a persistent anchor subsystem.

An anchor is a pose in the physical environment that is tracked by an XR device. As the device refines its understanding of the environment, anchors will be updated, allowing you to keep virtual content connected to a real-world position and orientation.

This abstract class should be implemented by an XR provider and instantiated using the SubsystemManager to enumerate the available XRPersistentAnchorSubsystemDescriptor s.

Properties

CurrentConfiguration

XRPersistentAnchorConfiguration? CurrentConfiguration

Get or set configuration with <name>XRPersistentAnchorConfiguration</name>

.. note::

This api calls into native, so getting or setting the configuration will return a deep copy Updated configurations need to be set to take effect

Events

debugInfoProvided

event debugInfoProvided()

Called when debug info is available

Each invocation of this event contains a XRPersistentAnchorDebugInfo object that contains arrays of XRPersistentAnchorNetworkRequestStatus, XRPersistentAnchorLocalizationStatus, and (experimental) XRPersistentAnchorFrameDiagnostics

OnConfigurationChanged

event OnConfigurationChanged()

Called when the subsystem's configuration changes

Methods

XRPersistentAnchorSubsystem

XRPersistentAnchorSubsystem()

Constructor. Do not invoke directly; use the SubsystemManager to enumerate the available XRPersistentAnchorSubsystemDescriptor s and call Create on the desired descriptor.

GetChanges

override TrackableChanges<XRPersistentAnchor> GetChanges(Allocator allocator)

Get the changes to anchors (added, updated, and removed) since the last call to GetChanges(Allocator).

    Parameters:

    allocator - An allocator to use for the NativeArrays in TrackableChanges<T>.

    Returns:

    Changes since the last call to GetChanges.

TryAddAnchor

bool TryAddAnchor(Pose pose, out XRPersistentAnchor anchor)

Attempts to create a new anchor with the provide pose.

    Parameters:

    pose - The pose, in session space, of the new anchor.

    anchor - The new anchor. Only valid if this method returns true.

    Returns:

    true if the new anchor was added, otherwise false.

TryRemoveAnchor

bool TryRemoveAnchor(TrackableId anchorId)

Attempts to remove an existing anchor with TrackableId anchorId.

    Parameters:

    anchorId - The id of an existing anchor to remove.

    Returns:

    true if the anchor was removed, otherwise false.

TryRestoreAnchor

bool TryRestoreAnchor(
XRPersistentAnchorPayload anchorPayload,
out XRPersistentAnchor anchor
)

Tries to restore an anchor

    Parameters:

    anchorPayload - The payload to restore the anchor with

    anchor - The restored anchor

    Returns:

    Whether or not the restoration was successful

GetVpsSessionId

bool GetVpsSessionId(out string vpsSessionId)

Get the vps session id, if any

    Parameters:

    vpsSessionId - The vps session id as 32 character hexidecimal upper-case string.

    Returns:

    True if vps session id is present, false otherwise

TryAddMap

bool TryAddMap(byte[] dataBytes)

Attempts to add map.

.. note::

This is an experimental feature, and is subject to breaking changes or deprecation without notice

    Parameters:

    dataBytes - Byte array of map data

    Returns:

    true if the new map was added, otherwise false.

TryAddGraph

bool TryAddGraph(byte[] dataBytes)

Attempts to add map graph.

.. note::

This is an experimental feature, and is subject to breaking changes or deprecation without notice

    Parameters:

    dataBytes - Byte array of map graph data

    Returns:

    true if the new map graph was added, otherwise false.