"We offer new support options and therefor the forums are now in read-only mode! Please check out our Support Center for more information." - Vuforia Engine Team

IVirtualButtonEventHandler Deprecated issue

Hello-

 

I am new to Unity/Vuforia and also do not have a great deal of experience with coding, so i apologize in advance if this is a dumb question.

I am using Unity version 2019.4.0f1 and Vuforia Package 9-2-7

I am trying to create Virtual Buttons by following along with this tutorial: https://www.youtube.com/watch?v=ElmzIq6stNI

Apparently, IVirtualButtonEventHandler is deprecated, which makes the script not work

 

 

The specific error i am getting is Assets\vb_anim.cs(6,39): error CS0246: The type or namespace name 'IVirtualButtonEventHandler' could not be found (are you missing a using directive or an assembly reference?)

This makes sense, as IVirtualButtonEventHandler is deprecated. However, when i remove it i get this error:

Assets\vb_anim.cs(16,57): error CS1061: 'VirtualButtonBehaviour' does not contain a definition for 'RegisterEventHandler' and no accessible extension method 'RegisterEventHandler' accepting a first argument of type 'VirtualButtonBehaviour' could be found (are you missing a using directive or an assembly reference?)

If i then remove or comment out vbBtnObj.GetComponent<VirtualButtonBehaviour>().RegisterEventHandler(this);, i do not get errors in the Unity console, however, the virtual button does not work.

I have no idea how to fix this

Thanks a million in advance. Script below

 

 

using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using Vuforia;

public class vbButton : MonoBehaviour, IVirtualButtonEventHandler {

    public GameObject vbBtnObj;     public Animator cubeAni;

    // Use this for initialization     void Start()     {         vbBtnObj = GameObject.Find("LacieBtn");         vbBtnObj.GetComponent<VirtualButtonBehaviour>().RegisterEventHandler(this);         cubeAni.GetComponent<Animator>();     }

    public void OnButtonPressed(VirtualButtonBehaviour vb)     {         cubeAni.Play("cube_animation");         Debug.Log("Button pressed");     }

    public void OnButtonReleased(VirtualButtonBehaviour vb)     {         cubeAni.Play("none");         Debug.Log("Button released");     } }

 

Hi,

WIth 8.6.7 we made some changes on how Vuforia Engine events are registered: ( info available in the release notes)