Hi,
I’m trying to export anchors from an immersive headset, save the data on a server, and then load it on other instances of the application so that every headset has the same anchors. For now I’m simply saving the data on disk.
I’ve followed the code from this Unity doc (see my version below) and I’m getting an error : calling “WorldAnchorTransferBatch.ExportAsync” lead to
The world anchors features are supposed to work on immersive headset, they work both in build and in editor for local persistant anchors, but exporting fails both in build and in editor.
Is it a bug or have I missed something ?
Thanks for your help !
Tom
Code :
private void ExportAnchors() {
WorldAnchorTransferBatch transferBatch = new WorldAnchorTransferBatch();
for (int i= 0; i < m_numOfTargets; i++) {
transferBatch.AddWorldAnchor("anchor_"+i, m_AnchorPoints[i].GetComponent<WorldAnchor>());
}
WorldAnchorTransferBatch.ExportAsync(transferBatch, OnExportDataAvailable, OnExportComplete);
}
private void OnExportComplete(SerializationCompletionReason completionReason) {
if (completionReason != SerializationCompletionReason.Succeeded) {
// If we have been transferring data and it failed,
// tell the client to discard the data
Debug.LogError("Anchors exporting failed");
} else {
// Tell the client that serialization has succeeded.
// The client can start importing once all the data is received.
Debug.Log("Anchors exporting succeded");
}
}
private void OnExportDataAvailable(byte[] data) {
// Send the bytes to the client. Data may also be buffered.
File.WriteAllBytes(Application.persistentDataPath+"/anchors.dat", data);
Debug.Log("Anchors data correctly written");
}
Setup :
- Windows 10 v 1709 / 16299.248
- HP immersive headset (I can also try on every other model if needed)
- Unity 2017.3.0p4 / 2017.3.1p1 / 2017.2.0p2
- MRTK from the 16th of january