Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WorldAnchor is exported failed on HoloLens2 #546

Open
GuangtongYang opened this issue Mar 16, 2022 · 2 comments
Open

WorldAnchor is exported failed on HoloLens2 #546

GuangtongYang opened this issue Mar 16, 2022 · 2 comments
Labels

Comments

@GuangtongYang
Copy link

Hello, everyone.

i try to apply to share worldanchor refer to this link
https://docs.microsoft.com/en-us/windows/mixed-reality/out-of-scope/local-anchor-transfers-in-unity
and i get SerializationCompletionReason.Unknownerror in hololens2 when i want to export worldanchor using WorldAnchorTransferBatch.ExportAsync(transferBatch, OnExportDataAvailable, OnExportComplete);
here are my codes:

private void ExportGameRootAnchor()
{
    WorldAnchorTransferBatch transferBatch = new WorldAnchorTransferBatch();
    WorldAnchor anchor = rootGameObject.GetComponent<WorldAnchor>();
    if (anchor == null)
    {
        anchor = rootGameObject.AddComponent<WorldAnchor>();
    }
    transferBatch.AddWorldAnchor(rootGameObject.name, anchor);
    DebugText.text = transferBatch.anchorCount.ToString();
    try
    {
        WorldAnchorTransferBatch.ExportAsync(transferBatch, OnExportDataAvailable, OnExportComplete);
    }
    catch 
    {
    }
}
private void OnExportDataAvailable(byte[] data)
{
    //exportAnchorData.AddRange(data);
     DebugText.text = "sending ";
     List<byte> sf = new List<byte>();
     sf.Add(55);//表明发送的是anchor信息
     sf.Add(44);
     sf.Add((byte)data.Length);
     sf.AddRange(data);
     byte[] sendBuffer = sf.ToArray();
     clientSocket.Send(sendBuffer);
     //TransferDataToClient(data); 
}
private void OnExportComplete(SerializationCompletionReason completionReason)
{
    if (completionReason != SerializationCompletionReason.Succeeded)
    {
        //SendExportFailedToClient();

        DebugText.text = "send failed +  " +completionReason;
    }
    else
    {
        //SendExportSucceededToClient();
        DebugText.text = "send success" + completionReason;
    }
}
@GuangtongYang
Copy link
Author

Have anyone met this before or someone know how to solve this porblem, thx!

@cheles
Copy link
Contributor

cheles commented May 9, 2022

@GtYang2333 you might want to review microsoft/MixedRealityToolkit-Unity#8796

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants