我使用Vuforia在Unity中创建了一个AR应用程序。我在场景中有一些虚拟按钮。我面临的问题是虚拟按钮是自己按下的。我无法弄清楚我做错了什么。所有按钮都位于名为“按钮”的图层中。这是虚拟Button处理程序脚本:
private List<GameObject> vbtns= new List<GameObject>();
// Use this for initialization
void Start () {
var goArray = FindObjectsOfType<GameObject>();
for(var i=0; i<goArray.Length; i++)
{
if(goArray[i].GetComponent<VirtualButtonBehaviour>())
{
//Debug.Log("The game component is " + goArray[i]);
goArray[i].GetComponent<VirtualButtonBehaviour>().RegisterEventHandler(this);
vbtns.Add(goArray[i]);
}
}
}
// Update is called once per frame
void Update () {
}
public void OnButtonPressed(VirtualButtonAbstractBehaviour vb)
{
Debug.Log("Button Pressed.");
Debug.Log("The name of the vbutton is "+ vb.VirtualButtonName);
SceneManager.LoadScene("scene_"+vb.VirtualButtonName,LoadSceneMode.Single);
}
public void OnButtonReleased(VirtualButtonAbstractBehaviour vb)
{
Debug.Log("Button Released");
}