首页 > 解决方案 > 在运行时设置 OnAutomaticHitTest 和 OnInteractiveHitTest

问题描述

我正在放置我的 Plane Stage 和 Plane Finder 并在运行时设置属性,但是有两个属性我不知道如何设置: OnAutomaticHitTestOnInteractiveHitTest.

我看到它需要某种类型的东西HitTestEvent,但我不知道如何在这里设置我的自定义函数。

有人能帮我吗?

标签: unity3dvuforia

解决方案


您可以在此处找到文档PlaneFinderBehaviour

本质上,您实际上并没有定义这些属性,而是使用它们来触发事件。

例如:

public class CustomPlaneFinderBehaviour : PlaneFinderBehaviour
{
    public void CustomIntPerformHitTest(Vector2 screenPosition)
    {
        //Triggered on interactive hit test
    }
    public void CustomAutoPerformHitTest(Vector2 screenPosition)
    {
        //Triggered on automatic hit test
    }
}

然后在检查器中,您可以通过按加号按钮并在框中选择当前脚本来定义事件。然后它为您提供更改被调用函数的选项。

此处已定义交互式命中测试,而自动命中测试尚未定义:

在此处输入图像描述


推荐阅读