【问题标题】:Unity and Vuforia virtual buttonUnity 和 Vuforia 虚拟按钮
【发布时间】:2020-02-26 16:51:51
【问题描述】:

我是 Unity + Vuforia 的新手,我正在开发一个带有虚拟按钮的 AR 应用程序。 我在 youtube 上看过很多视频,它们都使用相同的方法来处理虚拟按钮。 但是,IVirtualButtonEventHandler 似乎已被弃用,而且我还没有看到任何替代示例代码。

请帮忙 谢谢

【问题讨论】:

标签: c# unity3d vuforia


【解决方案1】:

似乎他们在版本 9 中弃用了 IVirtualButtonEventHandler 接口。只需从脚本中删除该接口并使用新方法单独添加处理程序:RegisterOnButtonPressed 和 RegisterOnButtonReleased。示例:

void Start()
{
    this.gameObject.GetComponent<VirtualButtonBehaviour>().RegisterOnButtonPressed(OnButtonPressed);
    this.gameObject.GetComponent<VirtualButtonBehaviour>().RegisterOnButtonReleased(OnButtonReleased);
}

public void OnButtonPressed(VirtualButtonBehaviour vb)
{
    print("*** button Pressed " + vb.VirtualButtonName);
}

public void OnButtonReleased(VirtualButtonBehaviour vb)
{
    print("*** button Released " + vb.VirtualButtonName);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多