Skip to main content

Reloc Keypoints

You can listen to OnRelocalizationPoints2DUpdated event for whenever the 2d keypoints are updated, which is after every frame that has finished evaluation. Alternatively, you can also use OnRelocalizationPoints3DUpdated for 3d keypoints.

Do note that you need to enable the Get Keypoints 2D or Get Keypoints 3D options under the Map Reloc Data Options in ARSharedAnchorManager components to actually receive the updated keypoints.

// ARSharedAnchorManager.cs

// Attach a callback to these events to listen for whenever the keypoints are updated
public delegate void RelocalizationPoints2DUpdated(Vector2 points);
public event RelocalizationPoints2DUpdated OnRelocalizationPoints2DUpdated;

public delegate void RelocalizationPoints3DUpdated(Vector3 points);
public event RelocalizationPoints3DUpdated OnRelocalizationPoints3DUpdated;

Usage Example

[SerializeField]
private ARSharedAnchorManager _sharedAnchorManager;

private void OnEnable()
{
// Subscribe to event
_sharedAnchorManager.OnRelocalizationPoints2DUpdated += Render2DKeypoints;
_sharedAnchorManager.OnRelocalizationPoints3DUpdated += Render3DKeypoints;
}

private void OnDisable()
{
// Unsubscribe to event
_sharedAnchorManager.OnRelocalizationPoints2DUpdated -= Render2DKeypoints;
_sharedAnchorManager.OnRelocalizationPoints3DUpdated -= Render3DKeypoints;
}

private void Render2DKeypoints(Vector2[] keypoints)
{
// Do something with the keypoints
}

private void Render3DKeypoints(Vector3[] keypoints)
{
// Do something with the keypoints
}