Log in or register to post comments

virtual button is not working

December 26, 2013 - 9:11am #1

I created new project and imported the virtualbutton unity package. Drag the ARCamera to Scene. ARCamera inspector Activated Loaddataset and drag the ImageTarget  then assign the virtualbutton to child of ImageTarget. Drag the VirtualButtonEventHandler.cs script to ImageTarget. But my app is not working. Is i need to create button on image also? I wrote code in xml file for virtualButton. Is it enough? 

virtual button is not working

December 26, 2013 - 11:46pm #9

It's working. Thanks. How can i play audio for each button? Is i need to create AudioSource for each button?

virtual button is not working

December 26, 2013 - 11:32pm #8

I created virtual button with my own target and my own ImageTarget. How to do action with below code? If i want to open url means, is below code correct? But nothing happen. See the attached images.

 

 public void OnButtonPressed(VirtualButtonBehaviour vb)
    {
        Debug.Log("OnButtonPressed for " + vb.name );
 
switch (vb.VirtualButtonName)
        {
            
            case "blue":
               Application.OpenURL ("http://unity3d.com/");
                break;
 
                      case "green":
               Application.OpenURL ("http://unity3d.com/");
                break;
        }
 
 
   
    }
AttachmentSize
Image icon cow_scaled.jpg25.04 KB
Image icon structure.PNG159.19 KB

virtual button is not working

December 26, 2013 - 8:25pm #7

I recommend that you start with the VB sample, import your own targets and replace the targets in the sample scene. You can then arrange the existing buttons as you need. Replace the existing VB event handlers on the ImageTargets with this one, which you can customize..

Name this script SimpleVBEventHandler.cs

 


using UnityEngine;


public class SimpleVBEventHandler :     MonoBehaviour,
                                            IVirtualButtonEventHandler
{


    #region PUBLIC_METHODS

    /// <summary>
    /// Called when the virtual button has just been pressed:
    /// </summary>
    public void OnButtonPressed(VirtualButtonAbstractBehaviour vb)
    {
        Debug.Log("OnButtonPressed for " + vb.name );
  
    }


    /// <summary>
    /// Called when the virtual button has just been released:
    /// </summary>
    public void OnButtonReleased(VirtualButtonAbstractBehaviour vb)
    {
        Debug.Log("OnButtonReleased for " + vb.name );
    }

    #endregion // PUBLIC_METHODS



    #region UNTIY_MONOBEHAVIOUR_METHODS

    void Start()
    {

        // Register with the virtual buttons TrackableBehaviour
        VirtualButtonBehaviour vb =
                            GetComponentInChildren<VirtualButtonBehaviour>();
        if (vb)
        {
            vb.RegisterEventHandler(this);
        }

    }


    void Update()
    {

    }

    #endregion // UNTIY_MONOBEHAVIOUR_METHODS



    #region PRIVATE_METHODS



    #endregion // PRIVATE_METHODS
}

.. you also may want to change the Sensitivity Setting on the VB's to HIGH for testing purposes. 

Try that approach and tell me if you're still stuck.

virtual button is not working

December 26, 2013 - 6:46pm #6

Really i didn't understand. Can you explain how can i setup in unity?

virtual button is not working

December 26, 2013 - 10:25am #5

You can't define the VB on the target image submitted to the TMS. You need to configure the VBs after the dataset has been downloaded. For Unity you can simply layout the VBs onto the target in the Editor.

What is it that you're attempting to accomplish?

virtual button is not working

December 26, 2013 - 9:49am #4

David: Confusing me, I upload attached image to TargetManager, but the xml file doesn't have the buttons scale? why? This is the xml file:

 

<?xml version="1.0" encoding="UTF-8"?>
<QCARConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="qcar_config.xsd">
  <Tracking>
    <ImageTarget name="wood" size="512.000000 358.000000" />
  </Tracking>
</QCARConfig>
AttachmentSize
Image icon wood.jpg177.26 KB

virtual button is not working

December 26, 2013 - 9:34am #3

Is i need to create the button on image itself while upload to TargetManager. And, i didn't modify the wood target image xml file. But it's not working. See the attached images.

 

 

 

AttachmentSize
Image icon ARCamera.PNG206.35 KB
Image icon ImageTarget.PNG191.64 KB
Image icon virtualbutton.PNG183.03 KB

virtual button is not working

December 26, 2013 - 9:18am #2

You don't need to modify the XML when working in Unity. Be sure that your buttons are over features in the image - they won't work over a blank space. Also be aware that the very edge of the image isn't used for detection and so buttons won't work there either.

If that advice doesn't help, please post a screen grab of your expanded scene in Unity.

Log in or register to post comments