- Home /
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.
For NOOBS the documentation is not at all clear here what needs to be entered from a base level of functionality.
From what I gather it shows how to dynamically create a button and perhaps how to register it, all in one code block....
Not all of us necessarily want to create it dynamically since some of us might not be at that stage yet.... or we have it already created it in the editor and we only want the code necessary so we can simply drop the action we want done into it like slipping bread into a toaster, man.
For me I don't always understand the code samples until I put something relevant into it then I can dig deeper to understand it better.
So those...." heres the code block...." and "Insert ACTION HERE" are perfect for noobs.
The example in the Vuforia documentation is terribly written and leaves alot of new developers walking away with a sour taste in their mouths when its actually pretty easy! this will be attempt number three for me. Im not walking away till I understand it and can use it effectively. Any help and CLARIFICATION or SI$$anonymous$$PLIFICATION would be helpful.
Answer by Jamora · Jul 29, 2013 at 10:51 PM
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
Your answer
Follow this Question
Related Questions
how can i create a count down AR object that depends on a variable of remainnig stock? 1 Answer
Extended tracking in unity using vuforia model target? 2 Answers
how to access the buttons when the AR camera is turned on. 0 Answers
How can I have vuforia text recognition read in a phrase instead of just a single word. 1 Answer
How do ı acces dji matrice100 camera in my augmented reality application?(Using vuforia sdk) 0 Answers