Log in or register to post comments

Virtual Button EventHandler Problem...

March 26, 2014 - 10:10am #1

Hello,

I experimented with the Vuforia Virtual Button Sample and everything worked well.

Now i wanted to try a simple virtual Button on my own.

I started a new project and added the Vuforia extension. I added a virtual Camera, an Imagetarget and a little ParticlySystem that is activated by the virtual button. 

Now i created my own simple Script:

using UnityEngine;
using System.Collections;

public class CustomVirtualButtonEventHandler : MonoBehaviour , 
IVirtualButtonEventHandler {
	
	ParticleSystem flames;
	
	void Start()
	{
		
		VirtualButtonBehaviour[] vbs = GetComponentsInChildren<VirtualButtonBehaviour>();
		for (int i = 0; i < vbs.Length; ++i)
		{
			vbs[i].RegisterEventHandler(this);
		}
		
		flames = GetComponentInChildren<ParticleSystem>();
		
	}
	
	
	void Update () {
		
	}
	
	public void OnButtonPressed( VirtualButtonBehaviour vb ){
		
		Debug.Log( vb.name +" Pressed" );
		
		flames.Play();
	}
	
	public void OnButtonReleased( VirtualButtonBehaviour vb ){
		
		Debug.Log( vb.name +" Released" );
		
		flames.Stop();
	}
}

 

As soon as i built i get an error:
"CustomVirtualButtonEventHandler.cs(4,14): Error CS0535: `CustomVirtualButtonEventHandler' does not implement interface member `IVirtualButtonEventHandler.OnButtonPressed(VirtualButtonAbstractBehaviour)' (CS0535) (Assembly-CSharp)"

But why isn't this possible? I copied it from moderator davidbeard in this post (https://developer.vuforia.com/forum/unity-3-extension-technical-discussion/virtual-buttons-0) so it should be fine? 

What am i missing? Did i miss to connect a database?

A thousand thanks

greetins

Jakob

 

Virtual Button EventHandler Problem...

June 15, 2018 - 5:37am #7

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using Vuforia;

public class fullscreen : MonoBehaviour, IVirtualButtonEventHandler

{

    private GameObject vbButtonObject;

    // Use this for initialization

    void Start()

    {

        vbButtonObject = GameObject.Find("fullb");

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

    }

    public void OnButtonPressed(VirtualButtonBehaviour vb)

    {

        Debug.Log("1");

    }

    public void OnButtonReleased(VirtualButtonBehaviour vb)

    {

        Debug.Log("2");

    }

    // Update is called once per frame

    void Update()

    {

    }

}

This is my codes for a project when I try VirtualButtonAbstractBehaviour instead of VirtualButtonBehaviour it's underlining it like there is a typo. My virtual button not working please help.

Virtual Button EventHandler Problem...

April 5, 2017 - 9:06am #6

this is my code. i have used 2 methods

1. using VirtualButtonBehaviour

2. using GameObject

both aren't working. please help!!!

 

 

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using Vuforia;

public class vb : MonoBehaviour, IVirtualButtonEventHandler {



public GameObject vbButtonObject;

public GameObject zombie;

public VirtualButtonBehaviour vbb;

 

void Start () {

  

  Debug.Log("in start{");

  vbButtonObject = GameObject.Find ("vButton");

  zombie = GameObject.Find ("zombie");

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

 

 

vbb = GetComponentInChildren<VirtualButtonBehaviour> ();

  vbb.RegisterEventHandler (this);



}

 



public void OnButtonPressed(VirtualButtonAbstractBehaviour vb){

  Debug.Log ("button pressed...");

}

public void OnButtonReleased(VirtualButtonAbstractBehaviour vb){

  Debug.Log ("button no pressed...");

}



// Update is called once per frame

void Update () {

 

}

}

Virtual Button EventHandler Problem...

August 29, 2016 - 11:20pm #5

Its

public void OnButtonPressed( VirtualButtonAbstractBehaviour vb )

instead of 

public void OnButtonPressed( VirtualButtonBehaviour vb )

Virtual Button EventHandler Problem...

March 27, 2014 - 4:47am #4

you're welcome.

Virtual Button EventHandler Problem...

March 27, 2014 - 4:15am #3

Thank you very much!! 

Virtual Button EventHandler Problem...

March 26, 2014 - 10:21am #2

The API in 2.8 has been slightly changed;

try replacing:

public void OnButtonPressed( VirtualButtonBehaviour vb ) {

 

with:

public void OnButtonPressed( VirtualButtonAbstractBehaviour vb ) {

 

 

Log in or register to post comments