Quantcast
Channel: Recent Discussions — Mixed Reality Developer Forum
Viewing all articles
Browse latest Browse all 10543

How to Import And Export WorldAnchor in Unity

$
0
0
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??


Viewing all articles
Browse latest Browse all 10543

Trending Articles