【问题标题】:Ar Anchor in Unity HubUnity Hub 中的 Ar 锚点
【发布时间】:2022-05-26 19:39:41
【问题描述】:

我正在尝试构建一个简单的 ar 模型,它只是将平面覆盖在图像目标上。但是几天来我收到了这个警告

1.Packages\package\Vuforia\Scripts\Internal\ARFoundationIntegration\ARFoundationFacade.cs(268,26):警告 CS0618:'ARAnchorManager.AddAnchor(Pose)' 已过时:'使用 AddComponent() 添加锚点。 (2020-10-06)'

2.Packages\package\Vuforia\Scripts\Internal\ARFoundationIntegration\ARFoundationFacade.cs(298,17):警告 CS0618:“ARAnchorManager.RemoveAnchor(ARAnchor)”已过时:“调用 ARAnchor 组件上的 Destroy() 以将其删除。 (2020-10-06)'

我第一次遇到这个问题,而且我也是这个领域的新手。有人可以指导解决这个问题。提前致谢!

【问题讨论】:

    标签: c# unity3d augmented-reality arcore vuforia


    【解决方案1】:

    该文档有点令人困惑,因为它仍然显示过时的方法,尽管详细显示它们已过时但没有指向较新文档的链接(此时)。

    查看一些可用的示例可能是最容易的 - 例如,这组包括使用 AddComponent 创建新 Anchor 的示例:https://github.com/Unity-Technologies/arfoundation-samples/blob/main/Assets/Scripts/AnchorCreator.cs

                // Note: the anchor can be anywhere in the scene hierarchy
                var gameObject = Instantiate(prefab, hit.pose.position, hit.pose.rotation);
    
                // Make sure the new GameObject has an ARAnchor component
                anchor = gameObject.GetComponent<ARAnchor>();
                if (anchor == null)
                {
                    anchor = gameObject.AddComponent<ARAnchor>();
                }
    

    有关 ARFoundtaion 的更多详细信息,请点击此处:https://developers.google.com/ar/develop/unity-arf/features

    【讨论】:

    • 感谢@Mick 的回复,我应该在ARFoundationFacade.cs 文件中输入这些代码行还是使用github 中提供的代码创建一个新的.cs 文件?
    • 实际上,您可能会发现从一个工作示例开始并根据需要对其进行修改是最容易的。
    • 如果您不介意,您可以逐步向我解释如何执行此操作吗?我真的很抱歉,因为我在这个领域非常缺乏经验
    • 实际上,代码实验室中有一些在线设置的分步说明可以帮助您:codelabs.developers.google.com/arcore-unity-ar-foundation#0
    猜你喜欢
    • 1970-01-01
    • 2022-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-15
    • 2019-10-18
    • 1970-01-01
    相关资源
    最近更新 更多