Log in or register to post comments

IVirtualButtonEventHandler Deprecated issue

June 19, 2020 - 10:09am #1

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");

    }

}

 

IVirtualButtonEventHandler Deprecated issue

June 25, 2020 - 2:00am #2

Hi,

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

Refactored the way how Unity application code can register for Vuforia Engine events. Instead of implementing event handling interfaces, application scripts can now register for individual callbacks. See the VuforiaSamples for more details.

As stated above, please check our Core Sample app from Unity, we demo the VirtualButton functionality; in a separte scene called: VirtualButtons

Thank you.

Vuforia Engine Support

Log in or register to post comments