Hello everyone.

The Mixed Reality Forums here are no longer being used or maintained.

There are a few other places we would like to direct you to for support, both from Microsoft and from the community.

The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.

For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.

If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.

And always feel free to hit us up on Twitter @MxdRealityDev.
Options

How to Import And Export WorldAnchor in Unity

private WorldAnchorStore anchorStore = null;
private WorldAnchor worldAnchor;
private WorldAnchorTransferBatch transferBatch;

private List<byte> exportingAnchorBytes = new List<byte>();

private void ExportWorldAnchor()
{
    transferBatch = new WorldAnchorTransferBatch();
    transferBatch.AddWorldAnchor("GameRootAnchor", worldAnchor);
    WorldAnchorTransferBatch.ExportAsync(transferBatch, OnExportDataAvailable, OnExportComplete);
}

private void OnExportComplete(SerializationCompletionReason completionReason)
{
    if (completionReason != SerializationCompletionReason.Succeeded)
    {

    }

    else
    {

    }
}

private void OnExportDataAvailable(byte[] data)
{
    exportingAnchorBytes.AddRange(data);
}

// This byte array should have been updated over the network from TransferDataToClient
private byte[] importedData;
private int retryCount = 3;

private void ImportRootGameObject()
{
    WorldAnchorTransferBatch.ImportAsync(importedData, OnImportComplete);
}

private void OnImportComplete(SerializationCompletionReason completionReason, WorldAnchorTransferBatch deserializedTransferBatch)
{
    if (completionReason != SerializationCompletionReason.Succeeded)
    {
        Debug.Log("Failed to import: " + completionReason.ToString());
        if (retryCount > 0)
        {
            retryCount--;
            WorldAnchorTransferBatch.ImportAsync(importedData, OnImportComplete);
        }
        return;
    }

    worldAnchor = deserializedTransferBatch.LockObject("gameRoot", this.gameObject);
}

I don't know how to import and export worldanchor well..

help me, plz..

1) I saw TransferDataToClient(data) in example,
but i don't know how to realize that on OnExportDataAvailable.

2) how to set byte[] importData??

Tagged:

Answers

  • Options

    Hey, @chanmob

    I'm not sure what seems to be the problem? You accumulate the bytes in a list of bytes. Now, when OnExportComplete is fired, your byte list should contain the complete bytes of the transfer batch. Pass it around, save it to file, send it to another HoloLens.

    It's hard to say what exactly doesn't work as it's not even clear whether this is code fragment of a MonoBehaviour, whether all your privates are initialized etc.

    Cheers

    Building the future of holographic navigation. We're hiring.

  • Options

    @stepan_stulov

    I need how to transfer to client that data of OnExportDataAvailable

Sign In or Register to comment.