Well, yes it is possible. And to make your app really use the AR feature you can implement the Virtual Button technique.
Honestly, when it comes to documentation, Qualcomm is useless. But since you use Unity with the Vuforia Extension, most features are luckily within the Unity Documentation.
I'll explain how you can achieve this in two ways:
1. Using Virtual Buttons (VB)
First off, start by adding/dropping a VB onto the scene from Assets>Qualcomm>Prefabs>Virtual Button
. Make sure the VB is a child of the Image Target used.
Create a new script for the Image Target that defines what your VB needs to do.
You'll start with registering the buttons:
void Start () {
VirtualButtonBehaviour[] vbs = transform.GetComponentsInChildren<VirtualButtonBehaviour> ();
for (int i=0; i < vbs.Length; ++i) {
vbs[i].RegisterEventHandler(this);
}
And now you go ahead and start with the function of the button
public void OnButtonPressed(VirtualButtonAbstractBehaviour vb){
//specify which button you want to function by using the if statement
if(vb.name=="ButtonName") { callButtonfunction();}
}
Similarly if you want a button to do something on release:
public void OnButtonReleased(VirtualButtonAbstractBehaviour vb){
//specify which button you want to function by using the if statement
if(vb.name=="ButtonName") { callButtonfunction();}
}
In case you want your button to control a Gameobject, then go ahead and declare the GameObject as a public variable in the class so that it can be accessed in the Inspector and assigned accordingly.
public GameObject human;
Where GameObject is the variable type and human is the variable name that we use for reference
Now again, as per what you're trying to gain, there are two ways of assigning what the callbuttonfunction()
can do.
Application.LoadLeve("Levelname")
This loads a new scene where the new object is loaded onto the same Image Target
Model.enabled(false)
and Elephant.enabled(true)
This simply disabled the current model and enabled the Elepant Model.
Setting these to public variables at the start of your class will make it easier to assign the models within Inspect element.
2. On-screen Buttons (OB)
- If you want on-screen buttons, then just parent the button UI to the Camera and position in a particular corner of the screen or something.
- Now if you function the button it will be within
void Update()
and you could use the scripting reference from Unity using the touch functions.
Really hope this helps you and everyone else who suffers from
absolutely NO support from Qualcomm.
Hit me up if you need more clarification.