Version: 2018.1
WMR testing during development
HoloLens Anchor Sharing

HoloLens WorldAnchor persistence

Persistence is a system for saving World Anchor states across multiple runs of the same application. This can be thought of as a “save game” functionality for physical locations in the real world. An example of this is remembering where a game board is placed in the world when the application re-launches.

El WorldAnchorStore proporciona una funcionalidad básica para guardar y cargar World Anchors. Recupere un WorldAnchorStore llamando aWorldAnchorStore.GetAsync y proporcionándole un callback. Su callback guarda el WorldAnchorStore devuelto para que pueda ser utilizado para futuras operaciones.

Para guardar un World Anchor existente, asígnele un nombre y llame a la función Guardar enWorldAnchorStore. Ver un ejemplo a continuación:

private void SaveAnchor()
{
    if (!this.savedAnchor) // only save this once
    {
        this.savedAnchor = this.MyWorldAnchorStore.Save("MyAnchor", MyWorldAnchor);
        if (!this.savedAnchor)
        {
            // Anchor failed to save to the store.
            // Handle errors here.
        }
    }
}

La carga es esencialmente un reflejo de lo anterior:

private void LoadAnchor()
{
    this.savedAnchor = this.Load("MyAnchor", MyWorldAnchor);
    if (!this.savedAnchor)
    {
        // An anchor with that name wasn't saved to the store.  
        // Handle errors here.
    }
}

Para eliminar un anchor (ancla) de la tienda, llame al método Delete en WorldAnchorStore. Para eliminar todos los anchors de la tienda, llame al método Clear.

WMR testing during development
HoloLens Anchor Sharing