Log in or register to post comments

[HELP] how to create virtual button in Unity

April 5, 2013 - 10:13pm #1

can somebody teach me how to create virtual button in unity?

[HELP] how to create virtual button in Unity

October 28, 2013 - 2:39am #7

Do a search for it and go through the dev guide and study the samples.

N

[HELP] how to create virtual button in Unity

October 25, 2013 - 8:26am #6

Can you teach me a virtual button?? I really need help,..
is there a tutorial that can help me?

[HELP] how to create virtual button in Unity

April 8, 2013 - 9:04am #5

so if i want to rotate the teapot i put it in this :

if (vbb != null)
                {
                    // Register the button with the event handler on the Wood target.
                    vbb.RegisterEventHandler(mImageTargetWood.GetComponent<VirtualButtonEventHandler>());
 
                    // Add a mesh to outline the button.
                    CreateVBMesh(vbb);
                }

right??

[HELP] how to create virtual button in Unity

April 7, 2013 - 3:59pm #4

Take a look at the ToggleVirtualButton method in the VirtualButtonsMenu.cs script associated w/ the ARCamera in the Virtual Buttons Unity sample.

Notice that you first have to deactivate the DataSet with which the VB is associated, based on its parent ImageTarget, and then you can create the VB instance and its mesh, and then reactivate the DataSet.

 

    private void ToggleVirtualButton(string name)
    {
        if (mImageTargetWood.ImageTarget != null)
        {
            // Get the virtual button if it exists.
            VirtualButton vb = mImageTargetWood.ImageTarget.GetVirtualButtonByName(name);

            if (vb != null)
            {
                // Destroy the virtual button if it exists.
                mImageTargetWood.DestroyVirtualButton(name);
            }
            else
            {
                // Get the position and scale originally used for this virtual button.
                Vector3 position, scale;
                if (mVBPositionDict.TryGetValue(name, out position) &&
                    mVBScaleDict.TryGetValue(name, out scale))
                {
                    // Deactivate the dataset before creating the virtual button.
                    ImageTracker imageTracker = (ImageTracker)
                                                TrackerManager.Instance.GetTracker(Tracker.Type.IMAGE_TRACKER);
                    DataSet dataSet = imageTracker.GetActiveDataSets().First();
                    imageTracker.DeactivateDataSet(dataSet);

                    // Create the virtual button.
                    VirtualButtonBehaviour vbb = mImageTargetWood.CreateVirtualButton(name,
                                                                                      new Vector2(position.x, position.z),
                                                                                      new Vector2(scale.x, scale.z));

                    if (vbb != null)
                    {
                        // Register the button with the event handler on the Wood target.
                        vbb.RegisterEventHandler(mImageTargetWood.GetComponent<VirtualButtonEventHandler>());

                        // Add a mesh to outline the button.
                        CreateVBMesh(vbb);
                    }

                    // If the Wood target isn't currently tracked hide the button.
                    if (mImageTargetWood.CurrentStatus == TrackableBehaviour.Status.NOT_FOUND)
                    {
                        vbb.GetComponent<Renderer>().enabled = false;
                    }

                    // Reactivate the dataset.
                    imageTracker.ActivateDataSet(dataSet);
                }
            }
        }
    }

 

[HELP] how to create virtual button in Unity

April 7, 2013 - 10:59am #3

yes. but i didnt understand how to create it from zero.

about the image target i've understand it.

[HELP] how to create virtual button in Unity

April 6, 2013 - 12:42pm #2

Hi, have you tried out the Virtual Button sample for Unity ?

 

Log in or register to post comments