Start/Stop Relocalization
The SDK provides a set of API start/stop relocalization for each shared anchor type.
Map-based Relocalization
// ARSharedAnchorManager.cs
// Start map-based relocalization with the default parameter
public void StartCloudMapRelocalization(int timeoutInMilliseconds = 0);
// Start map-based relocalization to find the shared anchor in a map with mapKey
public void StartCloudMapRelocalization(string mapKey, int timeoutInMilliseconds = 0);
Usage Example
[SerializeField]
private ARSharedAnchorManager _sharedAnchorManager;
private void Start()
{
_sharedAnchorManager.StartCloudMapRelocalization();
}
Image-based Relocalization
// ARSharedAnchorManager.cs
// Start image-based relocalization with the default parameter
public void StartImageRelocalization(int timeoutInMilliseconds = 0);
// Start image-based relocalization with the referenceImage as shared anchor when it's found
public void StartImageRelocalization(XRReferenceImage referenceImage, int timeoutInMilliseconds = 0);
Usage Example
[SerializeField]
private ARSharedAnchorManager _sharedAnchorManager;
private void Start()
{
_sharedAnchorManager.StartImageRelocalization();
}
Stopping Relocalization
// ARSharedAnchorManager.cs
// Stops any running relocalization process
public void StopRelocalization();
// Stops any running relocalization process
// and resets any relocalized shared anchors
public void ResetSharedAnchor();
Usage Example
[SerializeField]
private ARSharedAnchorManager _sharedAnchorManager;
private void OnDestroy()
{
_sharedAnchorManager.ResetSharedAnchor();
}