我使用的是Unity 4.7.0和Vuforia 5.0.10,我无法调用IVirtualButtonEventHandler
。
using UnityEngine;
using System.Collections;
public class VBEventHandler : MonoBehaviour, IVirtualButtonEventHandler
{
}
答案 0 :(得分:1)
我刚刚遇到过这个,希望你还在使用Unity& Vuforia。您需要使用Vuforia添加来进行呼叫。
using UnityEngine;
using System.Collections;
using Vuforia;
答案 1 :(得分:0)
注册虚拟按钮:
要向图像目标添加虚拟按钮,请将VirtualButton元素及其属性添加到.xml文件中的ImageTarget元素。
XML属性:
注册虚拟按钮代码后很简单:
using UnityEngine;
using System.Collections;
using Vuforia;
public class Custom_VirtualButton : MonoBehaviour, IVirtualButtonEventHandler
{
// Use this for initialization
void Start () {
// here it finds any VirtualButton Attached to the ImageTarget and register it's event handler and in the
//OnButtonPressed and OnButtonReleased methods you can handle different buttons Click state
//via "vb.VirtualButtonName" variable and do some really awesome stuff with it.
VirtualButtonBehaviour[] vbs = GetComponentsInChildren<VirtualButtonBehaviour>();
foreach (VirtualButtonBehaviour item in vbs)
{
item.RegisterEventHandler(this);
}
}
// Update is called once per frame
void Update () {
}
#region VirtualButton
public void OnButtonPressed(VirtualButtonAbstractBehaviour vb)
{
Debug.Log("Helllllloooooooooo");
}
public void OnButtonReleased(VirtualButtonAbstractBehaviour vb)
{
Debug.Log("Goooooodbyeeee");
}
#endregion //VirtualButton
}