Log in or register to post comments

`ButtonEvent' does not implement interface member

April 9, 2014 - 4:15am #1

Hei, can someone help me with this virtual button error? It shows like this:

Assets/ButtonEvent.cs(4,14): error CS0738: `ButtonEvent' does not implement interface member `IVirtualButtonEventHandler.OnButtonReleased(VirtualButtonAbstractBehaviour)' and the best implementing candidate `ButtonEvent.OnButtonPressed(VirtualButtonAbstractBehaviour)' return type `void' does not match interface member return type `void'

I only have that error on my project, what should i do to solve this?

Thanks

oh by the way this is my project script:

using UnityEngine;
using System.Collections;

public class ButtonEvent : MonoBehaviour, IVirtualButtonEventHandler{

    public GameObject identitas;
    public GameObject jadkul;
    public GameObject jadprak;
    
    void Start()
    {
        // Register with the virtual buttons TrackableBehaviour
        VirtualButtonBehaviour[] vbs = GetComponentsInChildren<VirtualButtonBehaviour>();
        for (int i = 0; i < vbs.Length; ++i)
        {
            vbs[i].RegisterEventHandler(this);
        }

        identitas = transform.FindChild("IDENTITAS").gameObject;
        jadkul = transform.FindChild("JADWAL KULIAH").gameObject;
        jadprak = transform.FindChild("JADWAL PRAKTIKUM").gameObject;
        
                identitas.renderer.enabled = false;
    }
    // Called when the virtual button has just been pressed:
    public void OnButtonPressed( VirtualButtonAbstractBehaviour vb ) {
        Debug.Log("OnButtonPressed");

        switch (vb.VirtualButtonName)
        {
            case "buttondata":
                Display( identitas );
                Hide( jadkul );
                Hide( jadprak );
                break;

            case "buttonjadkul":
                Display( jadkul );
                Hide( identitas );
                Hide( jadprak );
                break;
            
            case "buttonjadprak":
                Display( jadprak );
                Hide( identitas );
                Hide( jadprak );
                break;

        }

    }

void Display( GameObject obj){

        Renderer[] rendererComponents = obj.GetComponentsInChildren<Renderer>();

        // Enable rendering:
        foreach (Renderer component in rendererComponents)
        {
            component.enabled = true;
        }

}

void Hide( GameObject obj ){

        Renderer[] rendererComponents = obj.GetComponentsInChildren<Renderer>();

        // Disable rendering:
        foreach (Renderer component in rendererComponents)
        {
            component.enabled = false;
        }
}
}

I have 3 virtual buttons and 3 object. If the first button selected, the first object will show, if the second button selected, the first object will hide and the second will show

`ButtonEvent' does not implement interface member

January 9, 2019 - 2:32am #6

I have a similar issue. Kindly check into it. I am trying to generate two virtual button for an AR app.

 

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using Vuforia;

 

public class VirtualButtonEvent : MonoBehaviour, IVirtualButtonEventHandler

{

    private GameObject bmh;

    // register buttons for event handling

    void Start()

    {

        VirtualButtonBehaviour[] vbs = GetComponentsInChildren<VirtualButtonBehaviour>();

        for (int i = 0; i < vbs.Length; ++i) { vbs[i].RegisterEventHandler(this); }

        bmh = transform.FindChild("bmh").gameObject;

    }

    // button is "pressed" so change color of bmh

    public void OnButtonPressed(VirtualButtonAbstractBehaviour vb)

    {

        if (vb.VirtualButtonName == "Red") { bmh.renderer.material.color = Color.red; }

        if (vb.VirtualButtonName == "Blue") { bmh.renderer.material.color = Color.blue; }

    }

    // change bmh back to white

    public void OnButtonReleased(VirtualButtonAbstractBehaviour vb)

    {

        if (vb.VirtualButtonName == "Red") { bmh.renderer.material.color = Color.white; }

        if (vb.VirtualButtonName == "Blue") { bmh.renderer.material.color = Color.white; }

    }

}

`ButtonEvent' does not implement interface member

January 5, 2019 - 2:04am #5

Can you help me with my error i got the same error but i add that to in my codes but the error did not disappear  this is the error

" Assets/Scripts/MyScript/vb_skeleton.cs: error CS0535: 'vb_skeleton' does not implement interface member 'Vuforia.IVirtualButtonEventHandler.OnButtonPressed'(Vuforia.VirtualButtonAbstractBehaviour) "

" Assets/Scripts/MyScript/vb_skeleton.cs: error CS0535: 'vb_skeleton' does not implement interface member 'Vuforia.IVirtualButtonEventHandler.OnButtonReleased'(Vuforia.VirtualButtonAbstractBehaviour) "

 

this is my codes

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using UnityEngine.SceneManagement;

using UnityEngine.EventSystems;

using UnityEngine.UI;

using Vuforia;

public class vb_Skeleton : MonoBehaviour, IVirtualButtonEventHandler {

    public GameObject vbBtnObj;

    public Animator CubeAni;

    // Use this for initialization

    void Start()

    {

        vbBtnObj = GameObject.Find("SkeletonBtn");

        vbBtnObj.GetComponent<VirtualButtonBehaviour>().RegisterEventHandler(this);

        CubeAni.GetComponent<Animator>();

    }

    public void OnButtonPressed(VirtualButtonBehaviour vb)

    {

        CubeAni.Play("SkeletonAnim");

        Debug.Log("BTN Pressed");

    }

    public void OnButtonReleased(VirtualButtonBehaviour vb)

    {

        CubeAni.Play("none");

        Debug.Log("BTN Released");

    }

    // Update is called once per frame

    void Update () {



}

}

`ButtonEvent' does not implement interface member

April 9, 2014 - 5:10am #4

Thanks Alessandro, after i add that, i have no error and the app work fine

Glad to hear.

 

is there something wrong with my script?

That's just application logic, I cannot debug your code to deliver your specific application behaviour.

 

 

`ButtonEvent' does not implement interface member

April 9, 2014 - 4:46am #3

Thanks Alessandro, after i add that, i have no error and the app work fine, but it only show one object and no virtual button. I have 3 objects and 3 buttons, i want to show each object in each button. I mean, If the first button selected, the first object will show, if the second button selected, the first object will hide and the second will show

is there something wrong with my script?

`ButtonEvent' does not implement interface member

April 9, 2014 - 4:23am #2

Add this:

public void OnButtonReleased( VirtualButtonAbstractBehaviour vb ) { 

}

 

Log in or register to post comments