无法更新Microsoft AzureSpatialAnchor [英] Update a Microsoft AzureSpatialAnchor not possible
问题描述
我正在开发一个统一的应用程序,我正在使用天蓝色的空间锚点.我发现无法更新现有的cloudAnchor.我试过了:
I develop an unity application an I am working with azure spatial anchors. I found no possibility to update a already existing cloudAnchor. I tried this:
protected virtual async Task SaveCurrentObjectAnchorToCloudAsync()
{
// Get the cloud-native anchor behavior
CloudNativeAnchor cna = cubeInstance.GetComponent<CloudNativeAnchor>();
// If the cloud portion of the anchor hasn't been created yet, create it
if (cna.CloudAnchor == null) {
cna.NativeToCloud();
}
// Get the cloud portion of the anchor
CloudSpatialAnchor cloudAnchor = cna.CloudAnchor;
// In this sample app we delete the cloud anchor explicitly, but here we show how to set an anchor to expire automatically
//cloudAnchor.Expiration = DateTimeOffset.Now.AddDays(7);
while (!CloudManager.IsReadyForCreate)
{
await Task.Delay(330);
float createProgress = CloudManager.SessionStatus.RecommendedForCreateProgress;
Debug.Log("create Progress");
Debug.Log(createProgress);
if(createProgress > 1)
{
createProgress = 1;
}
feedbackText.text = $"{ createProgress: 0 %}";
Debug.Log($"Move your device to capture more environment data: {createProgress:0%}");
}
bool success = false;
feedbackText.text = "Saving...";
try
{
if(currentCloudAnchor == null)
{
// Actually save
await CloudManager.CreateAnchorAsync(cloudAnchor);
} else {
await CloudManager.Session.UpdateAnchorPropertiesAsync(cloudAnchor);
}
// Store
currentCloudAnchor = cloudAnchor;
// Success?
success = currentCloudAnchor != null;
if (success && !isErrorActive)
{
// Await override, which may perform additional tasks
// such as storing the key in the AnchorExchanger
await OnSaveCloudAnchorSuccessfulAsync();
}
else
{
OnSaveCloudAnchorFailed(new Exception("Failed to save, but no exception was thrown."));
}
}
catch (Exception ex)
{
OnSaveCloudAnchorFailed(ex);
}
}
该方法的第一个调用正在工作.在天蓝色的云中创建了一个spartialAnchor.在第二个呼叫中,当我想更新锚点时,我首先git错误:
The first call of the method is working. A spartialAnchor in the azure cloud was created. In the second call when I want to update the anchor I first git the error:
InvalidOperationException:在将SpatialAnchor保存到云后,不能使用SpatialAnchor :: SetExpirationUtcTimeMS更改到期时间.目前不支持该功能.响应简历:. 08-18 01:07:09.845 31868 31927 E Unity:at Microsoft.Azure.SpatialAnchors.NativeLibraryHelpers.CheckStatus(System.IntPtr句柄,Microsoft.Azure.SpatialAnchors.status值)[0x00109]在C:... \ Assets \ AzureSpatialAnchors.SDK \ Plugins \ Common \ AzureSpatialAnchorsBridge.cs:5381
InvalidOperationException: SpatialAnchor::SetExpirationUtcTimeMS cannot be used to change the expiration time after the SpatialAnchor has been saved to the Cloud. That functionality is not currently supported.. Request CV: . Response CV: . 08-18 01:07:09.845 31868 31927 E Unity : at Microsoft.Azure.SpatialAnchors.NativeLibraryHelpers.CheckStatus (System.IntPtr handle, Microsoft.Azure.SpatialAnchors.status value) [0x00109] in C:...\Assets\AzureSpatialAnchors.SDK\Plugins\Common\AzureSpatialAnchorsBridge.cs:5381
要摆脱它,我必须删除此行:
To get rid of it I had to remove this line:
cloudAnchor.Expiration = DateTimeOffset.Now.AddDays(7);
但是云锚的更新仍然无法正常进行.我收到此错误:
But the update of the cloud anchor is still not working. I get this error:
OnError-指定的空间锚已经与其他商店关联
OnError - The specified spatial anchor is already associated with a different store
我也尝试使用此行进行更新
I tried also to use this line for an update
await CloudManager.CreateAnchorAsync(cloudAnchor);
我收到此错误:
无法保存锚点System.InvalidOperationException:.要求简历:.响应简历:. 08-18 01:20:07.661 5849 5909 I Unity:位于Microsoft.Azure.SpatialAnchors.NativeLibraryHelpers.CheckStatus(System.IntPtr句柄,Microsoft.Azure.SpatialAnchors.status值)[0x00109],位于C:... \ Assets \ AzureSpatialAnchors.SDK \插件\ Common \ AzureSpatialAnchorsBridge.cs:5381 08-18 01:20:07.661 5849 5909 I Unity:在Microsoft:Azure.SpatialAnchors.CloudSpatialAnchorSession +<> c__DisplayClass71_0.b__0()在C:\ Users \ ppelluda \ Documents \ Projects \ shared-experiences-tests \ Assets \ AzureSpatialAnchors.SDK \ Plugins \ Common \ AzureSpatialAnchorsBridge.cs:7162
Failed to save anchor System.InvalidOperationException: . Request CV: . Response CV: . 08-18 01:20:07.661 5849 5909 I Unity : at Microsoft.Azure.SpatialAnchors.NativeLibraryHelpers.CheckStatus (System.IntPtr handle, Microsoft.Azure.SpatialAnchors.status value) [0x00109] in C:...\Assets\AzureSpatialAnchors.SDK\Plugins\Common\AzureSpatialAnchorsBridge.cs:5381 08-18 01:20:07.661 5849 5909 I Unity : at Microsoft.Azure.SpatialAnchors.CloudSpatialAnchorSession+<>c__DisplayClass71_0.b__0 () [0x00001] in C:\Users\ppelluda\Documents\Projects\shared-experiences-tests\Assets\AzureSpatialAnchors.SDK\Plugins\Common\AzureSpatialAnchorsBridge.cs:7162
这时,我只看到删除azure的curent spaceAnchor并创建一个新选项的选项.这不是正确的方法.
At this moment I just see the option to delete the curent spatialAnchor in azure and create a new one. This can't be the correct approach.
更新锚点的正确方法是什么?
推荐答案
这个问题/问题已经提出过,所以我可以为您提供最新的答案.当前无法更新已经存在的锚点.您将需要删除旧的锚点并创建一个新的锚点.
This question/problem has been posed before, so I can update you on the answer. Currently there is no way to update an already existing anchor. You will need to delete the old anchor and create a new one.
这篇关于无法更新Microsoft AzureSpatialAnchor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!