Partager via


AnchorConverter.ReplaceSpatialAnchor(Object, TrackableId) Method

Definition

Replaces the underlying platform anchor for an existing XRAnchor/ARAnchor represented by the given TrackableId, so the Unity anchor will instead be located by the given SpatialAnchor.

public static UnityEngine.XR.ARSubsystems.TrackableId ReplaceSpatialAnchor (object spatialAnchor, UnityEngine.XR.ARSubsystems.TrackableId existingId);
static member ReplaceSpatialAnchor : obj * UnityEngine.XR.ARSubsystems.TrackableId -> UnityEngine.XR.ARSubsystems.TrackableId
Public Shared Function ReplaceSpatialAnchor (spatialAnchor As Object, existingId As TrackableId) As TrackableId

Parameters

spatialAnchor
Object

Must be a Windows.Perception.Spatial.SpatialAnchor.

existingId
UnityEngine.XR.ARSubsystems.TrackableId

An id representing an existing XRAnchor/ARAnchor.

Returns

UnityEngine.XR.ARSubsystems.TrackableId

Returns the trackable id representing the Unity anchor or UnityEngine.XR.ARSubsystems.TrackableId.invalidId if the conversion was unsuccessful.

Remarks

Use this function instead of FromPerceptionSpatialAnchor(Object) to avoid creating new ARAnchor on every new platform anchor.

Applies to