Vuforia Virtual buttons question

When i add virtual buttons to my project I write a script for it, assign the script to the ImageTarget, Test it and nothing happens when i hover my finger over the Virtual Button it does nothing at all.

Heres my script:

using UnityEngine;
using System.Collections;
 
public class VirtualButtonEventHandler : MonoBehaviour, IVirtualButtonEventHandler {
 
	char x;
	char a = 'a';
	
	public GameObject Keyboard;
	public GameObject Text;
	
    // Use this for initialization
    void Start () {
		
	Keyboard = transform.FindChild("Text").gameObject;
		
 
	}
	
	public void OnButtonPressed(VirtualButtonBehaviour vb){
		
		Debug.Log ("Pressed");
		GetComponent<TextMesh>().text = "test";
	}
		
	public void OnButtonReleased(VirtualButtonBehaviour vb){
		Debug.Log("Released");
	}
	
	void Update () {
		
	}
	
}

Please tell me the problem or give me a tutorial because there are no tutorials on the Qualcomm website that tell you how to do it.

1 Answer

1

You need to read the Dev Guide section for Vuforia. Especially the documentation for Virtual Buttons in Unity.

From a quick skim, it would seem that you’re not registering your button handlers to the Vuforia event handler. Place this code in your Start method. I assume your virtual button behaviours are also names vbb, as that’s how it’s like in their site…

// Register an event handler
// Here we assume this class extends IVirtualButtonEventHandler
vbb.RegisterEventHandler(this);

On the website it doesn't tell you how to do something when the button is pressed

Only you know what you want your buttons to do, so the Vuforia pages won't help there. Once you know what you want your buttons to do, you put the implementation inside the OnButtonPressed -function. You get the Vuforia AR system to call your OnButtonPressed function by subscribing to the Event handler in the ImageTargetBehavior script. It's all in the links I posted.

Ok so EXACTLY WHERE DO WE PUT THIS???? Does it go inside the event handler or prior to it? does it go in the declarations? Total noob here... i know common sense says prior... but NOTHING tells you WHERE to... so frustrating. Some one please provide the complete code