Eryco Ld Tia
Eryco Ld Tia

Reputation: 19

Vuforia namespace not found

I made a virtual button for augmented reality with Vuforia:

using UnityEngine;
using System.Collections.Generic;

public class VBGordangDuaEventHandler : MonoBehaviour, IVirtualButtonEventHandler
{
    #region PUBLIC_MEMBER_VARIABLES

    /// <summary>
    /// The materials that will be set for the teapot model
    /// </summary>
    public Material[] m_TeapotMaterials;
    public AudioSource VBgordangduahitam;
    public AudioSource VBgordangduamerah;

    #endregion $3$



    #region PRIVATE_MEMBER_VARIABLES

private GameObject mTeapot;
private List<Material> mActiveMaterials;

#endregion $4$



#region UNITY_MONOBEHAVIOUR_METHODS

void Start()
{
    // Register with the virtual buttons TrackableBehaviour
    VirtualButtonBehaviour[] vbs = GetComponentsInChildren<VirtualButtonBehaviour>();
    for (int i = 0; i < vbs.Length; ++i)
    {
        vbs[i].RegisterEventHandler(this);
    }
    
    // Get handle to the teapot object
    //      mTeapot = transform.FindChild("teapot").gameObject;
    
    // The list of active materials
    mActiveMaterials = new List<Material>();
}

#endregion $9$



#region PUBLIC_METHODS

/// <summary>
/// Called when the virtual button has just been pressed:
/// </summary>
public void OnButtonPressed(VirtualButtonAbstractBehaviour vb)
{
    Debug.Log("OnButtonPressed::" + vb.VirtualButtonName);
    
    /*if (!IsValid())
    {
        return;
    }*/
    
    // Add the material corresponding to this virtual button
    // to the active material list:
    switch (vb.VirtualButtonName)
    {
    case "VBgordangduahitam":
        Debug.Log ("gordangduahitam");
        suaragordangduahitam.Play ();
        break;
        
    case "VBgordangduamerah":
        Debug.Log ("gordang2merah");
        suaragordangduamerah.Play ();
        break;
        
    }
    
    // Apply the new material:
    /*if (mActiveMaterials.Count > 0)
        mTeapot.renderer.material = mActiveMaterials[mActiveMaterials.Count - 1];*/
}


/// <summary>
/// Called when the virtual button has just been released:
/// </summary>
public void OnButtonReleased(VirtualButtonAbstractBehaviour vb)
{
    if (!IsValid())
    {
        return;
    }
    
    // Remove the material corresponding to this virtual button
    // from the active material list:
    switch (vb.VirtualButtonName)
    {
    case "red":
        mActiveMaterials.Remove(m_TeapotMaterials[0]);
        break;
        
    case "blue":
        mActiveMaterials.Remove(m_TeapotMaterials[1]);
        break;
        
    case "yellow":
        mActiveMaterials.Remove(m_TeapotMaterials[2]);
        break;
        
    case "green":
        mActiveMaterials.Remove(m_TeapotMaterials[3]);
        break;
    }
    
    // Apply the next active material, or apply the default material:
    /*if (mActiveMaterials.Count > 0)
        mTeapot.renderer.material = mActiveMaterials[mActiveMaterials.Count - 1];
    else
        mTeapot.renderer.material = m_TeapotMaterials[4];*/
}


private bool IsValid()
{
    // Check the materials and teapot have been set:
    return  mTeapot != null;
}

#endregion $35$

Why do I get the following errors?

1): Error CS0246: The type or namespace name 'IVirtualButtonEventHandler' could not be found (are you missing a using directive or an assembly reference?) (CS0246) (Assembly-CSharp)

2): Error CS0246: The type or namespace name 'VirtualButtonAbstractBehaviour' could not be found (are you missing a using directive or an assembly reference?) (CS0246) (Assembly-CSharp)

3): Error CS0246: The type or namespace name 'VirtualButtonAbstractBehaviour' could not be found (are you missing a using directive or an assembly reference?) (CS0246) (Assembly-CSharp)

4): Error CS0246: The type or namespace name 'VuforiaBehaviourComponentFactory' could not be found (are you missing a using directive or an assembly reference?) (CS0246) (Assembly-CSharp-Editor)

How can I resolve these errors?

Upvotes: 0

Views: 7620

Answers (2)

digiliooo
digiliooo

Reputation: 841

Try adding

using Vuforia;

To the top of your code. As @ShaiAharoni mentioned in their comment, you need to reference the Vuforia DLLs.

Other references you may need include

using UnityEngine;
using System.Collections.Generic;

Upvotes: 3

ehh
ehh

Reputation: 3480

I assume that you copy the example from

https://developer.vuforia.com/forum/unity-3-extension-technical-discussion/virtual-buttons-no-response-tap

Login / register and download the example. According to your post, you didn't add references to the dlls and those are the errors you get. If you download the code example, you might get the dlls so you can refer your code example accordingly.

Upvotes: 0

Related Questions