Develop
Develop
Select your platform

Spatial Anchors Unreal C++ Reference

Updated: Sep 4, 2024

Anchor Types

FOculusXRUUID

FunctionDescription
IsValidUUID
True if this UUID is non-zero.
ToString
Converts the internal UUID representation into a string you can print.

FOculusXRUint64

FunctionDescription
GetValue
Returns the internal uint64.
SetValue
Sets the internal uint64.

FOculusXRSpaceDiscoveryInfo

VariableDescription
Filters
The list of filters to use in a discovery request.

FOculusXRAnchorsDiscoverResult

VariableDescription
Space
The anchor handle for the discovered anchor.
UUID
The persistent UUID for the discovered anchor.

UOculusXRSpaceDiscoveryIdsFilter

VariableDescription
UUIDs
The list of UUIDs to find during the discovery request.

UOculusXRSpaceDiscoveryComponentsFilter

VariableDescription
Component
The component that must be present on any anchor returned during the discovery request.

Delegate Types

DelegateParameters
FOculusXRSpatialAnchorCreateDelegate
EOculusXRAnchorResult::Type Result,
UOculusXRAnchorComponent* Anchor
FOculusXRSaveAnchorsDelegate
EOculusXRAnchorResult::Type Result,
const TArray<UOculusXRAnchorComponent*>& SavedAnchors
FOculusXREraseAnchorsDelegate
EOculusXRAnchorResult::Type Result,
const TArray<UOculusXRAnchorComponent*>& ErasedAnchors,
const TArray<FOculusXRUInt64>& ErasedAnchorHandles,
const TArray<FOculusXRUUID>& ErasedAnchorUUIDs
FOculusXRDiscoverAnchorsResultsDelegate
const TArray<FOculusXRAnchorsDiscoverResult>& DiscoveredAnchors
FOculusXRDiscoverAnchorsCompleteDelegate
EOculusXRAnchorResult::Type Result
FOculusXRAnchorShareDelegate
EOculusXRResult::Type Result,
const TArray<UOculusXRAnchorComponent*> Anchors,
const TArray<uint64> Users
FOculusXRGetSharedAnchorsDelegate
EOculusXRAnchorResult::Type Result,
const TArray<FOculusXRAnchorsDiscoverResult>& Results

Function Signatures

Create Spatial Anchor

bool CreateSpatialAnchor(
   const FTransform& InTransform,
   AActor* TargetActor,
   const FOculusXRSpatialAnchorCreateDelegate& ResultCallback,
   EOculusXRAnchorResult::Type& OutResult);
InputDescription
InTransform
The world space location to attempt to create the anchor at.
TargetActor
The Actor to attach the created spatial anchor to.
ResultCallback
The callback executed when the create succeeds or fails.
OutResult
The non-async immediate return code after starting the call.

Save Spatial Anchors

bool SaveAnchors(
   const TArray<UOculusXRAnchorComponent*>& Anchors,
   const FOculusXRSaveAnchorsDelegate& ResultCallback,
   EOculusXRAnchorResult::Type& OutResult);
InputDescription
Anchors
The list of anchors to save.
ResultCallback
The callback executed when the save succeeds or fails.
OutResult
The non-async immediate return code after starting the call.

Discover Spatial Anchors

bool DiscoverAnchors(
   const FOculusXRSpaceDiscoveryInfo& DiscoveryInfo,
   const FOculusXRDiscoverAnchorsResultsDelegate& DiscoveryResultsCallback,
   const FOculusXRDiscoverAnchorsCompleteDelegate& DiscoveryCompleteCallback,
   EOculusXRAnchorResult::Type& OutResult);
InputDescription
DiscoveryInfo
The structure containing the list of filters to apply to the discovery request.
DiscoveryResultsCallback
The callback executed every time anchors are found. Can fire zero or more times.
DiscoveryCompleteCallback
The callback executed once the discovery request is complete.
OutResult
The non-async immediate return code after starting the call.

Erase Spatial Anchors by Component

bool EraseAnchors(
   const TArray<UOculusXRAnchorComponent*>& Anchors,
   const FOculusXREraseAnchorsDelegate& ResultCallback,
   EOculusXRAnchorResult::Type& OutResult);
InputDescription
Anchors
The list of anchors to erase.
ResultCallback
The callback executed when the erase succeeds or fails.
OutResult
The non-async immediate return code after starting the call.

Erase Spatial Anchors by UUID or AnchorHandle

bool EraseAnchors(
   const TArray<FOculusXRUInt64>& AnchorHandles,
   const TArray<FOculusXRUUID>& AnchorUUIDs,
   const FOculusXREraseAnchorsDelegate& ResultCallback,
   EOculusXRAnchorResult::Type& OutResult);
InputDescription
AnchorHandles
The list of AnchorHandles associated with anchors you intend to erase.
AnchorUUIDs
The list of AnchorUUIDs associated with anchors you intend to erase.
ResultCallback
The callback executed when the erase succeeds or fails.
OutResult
The non-async immediate return code after starting the call.

Destroy Spatial Anchor

bool DestroyAnchor(
   uint64 AnchorHandle,
   EOculusXRAnchorResult::Type& OutResult);
InputDescription
AnchorHandle
The handle to the anchor you want to destroy.
OutResult
The result code after requesting to destroy the anchor.

Share Spatial Anchors

bool ShareAnchors(
   const TArray<UOculusXRAnchorComponent*>& Anchors,
   const TArray<uint64>& OculusUserIDs,
   const FOculusXRAnchorShareDelegate& ResultCallback,
   EOculusXRAnchorResult::Type& OutResult);
InputDescription
Anchors
The list of anchors to share.
OculusUserIDs
The list of users to share the specified anchors with. Each uint64 is a User ID.
ResultCallback
The callback executed when the share succeeds or fails.
OutResult
The non-async immediate return code after starting the call.

Share Spatial Anchors with Group

TSharedPtr<FShareAnchorsWithGroups> ShareAnchorsAsync(
   const TArray<FOculusXRUInt64>& AnchorHandles,
   const TArray<FOculusXRUUID>& Groups,
   const FShareAnchorsWithGroups::FCompleteDelegate& OnComplete);
InputDescription
AnchorHandles
The list of anchors to share.
Groups
The list of groups to share the specified anchors with.
OnComplete
The callback executed when the share succeeds or fails.
OutputDescription
TSharedPtr<FShareAnchorsWithGroups>
The resulting async request object.

Get Shared Spatial Anchors

bool GetSharedAnchors(
    const TArray<FOculusXRUUID>& AnchorUUIDs,
    const FOculusXRGetSharedAnchorsDelegate& ResultCallback,
    EOculusXRAnchorResult::Type& OutResult);
InputDescription
AnchorUUIDs
The list of anchors to attempt to retrieve.
ResultCallback
The callback executed when the request succeeds or fails.
OutResult
The non-async immediate return code after starting the call.

Get Shared Spatial Anchors from Group

TSharedPtr<FGetAnchorsSharedWithGroup> GetSharedAnchorsAsync(
   const FOculusXRUUID& Group,
   const FGetAnchorsSharedWithGroup::FCompleteDelegate& OnComplete);
InputDescription
Group
The group to retrieve anchors from.
OnComplete
The callback executed when the request succeeds or fails.
OutputDescription
TSharedPtr<FGetAnchorsSharedWithGroup>
The resulting async request object.
Did you find this page helpful?
Thumbs up icon
Thumbs down icon