Skip to main content
Version: 3.4

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();

// methods

XRPersistentAnchorSubsystem();
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);

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>

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

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