原创文档,转载请注明地址http://blog.csdn.net/fdbvm/article/details/79324718
{
WorldAnchorStore.GetAsync(StoreLoaded);
}
{
this.anchorStore = store;
}
transferBatch.AddWorldAnchor(exportingAnchorName, transform.GetComponent<WorldAnchor>());
WorldAnchorTransferBatch.ExportAsync(transferBatch, OnExportDataAvailable, OnExportComplete);
private void OnExportComplete(SerializationCompletionReason completionReason)
{
if (completionReason != SerializationCompletionReason.Succeeded)
{
Debug.Log("share anchor complete");
}
else
{ }
}
{
exportingAnchorBytes.AddRange(data);
}
int retryCount = 5;
private void OnImportComplete(SerializationCompletionReason completionReason, WorldAnchorTransferBatch deserializedTransferBatch)
{
if (completionReason != SerializationCompletionReason.Succeeded)
{
Debug.Log("Failed to import: " + completionReason.ToString());
if (retryCount > 0)
{
retryCount--;
WorldAnchorTransferBatch.ImportAsync(exportingAnchorBytes.ToArray(), OnImportComplete);
}
return;
}
string[] ids = deserializedTransferBatch.GetAllIds();
Debug.Log("load anchor count " + ids.Length);
foreach (string id in ids)
{
Debug.Log("load anchor "+id);
if (cubeTransform.gameObject != null&&id.Equals(exportingAnchorName))
{
Debug.Log("find anchor form share");
if (cubeTransform.GetComponent<WorldAnchor>() == null) cubeTransform.gameObject.AddComponent<WorldAnchor>();
deserializedTransferBatch.LockObject(id, cubeTransform.gameObject);
return;
}
}
}