By YOBA
on Mon, 05/16/2016 - 11:36
i would like to make an animation play on virtualbutton pressed.
but i get this error: Assets/Scripts/VirtualButtonHandler.cs(27,45): error CS0246: The type or namespace name `VirtualButtonBehaviour' could not be found. Are you missing a using directive or an assembly reference?
Please help me sir.
this is my code:
using UnityEngine; using System.Collections; using System.Collections.Generic; using System.Runtime.InteropServices; using System; public class VirtualButtonHandler : MonoBehaviour, Vuforia.IVirtualButtonEventHandler{ private GameObject mattress; // Use this for initialization 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 mattress = GameObject.Find("mattress").gameObject; } // Called when the virtual button has just been pressed: public void OnButtonPressed(VirtualButtonBehaviour vb) { Debug.Log("OnButtonPressed"); // Add the material corresponding to this virtual button // to the active material list: switch (vb.VirtualButtonName) { case "green": mattress.animation.Play("movingMattress"); mattress.animation.wrapMode = WrapMode.Once; break; } } }