VbtnDo.cs 1.25 KB
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Vuforia;

public class VbtnDo : MonoBehaviour, IVirtualButtonEventHandler
{
    VirtualButtonBehaviour virtualButtonBehaviour;
    private AudioSource sound;
    public GameObject ps;
    public GameObject star;
    
    // Start is called before the first frame update
    void Start()
    {
        virtualButtonBehaviour = GetComponentInChildren<VirtualButtonBehaviour>();
        virtualButtonBehaviour.RegisterEventHandler(this);
        Debug.Log("command reached in the expected position");
        
        sound = GetComponent<AudioSource>();

        ps = GameObject.Find("PsDo");
        ps.SetActive(false);

        star = GameObject.Find("StarDo");
        star.SetActive(false);
    }

    public void OnButtonPressed(VirtualButtonBehaviour vb)
    {
        sound.Play();
        ps.SetActive(true);
        star.SetActive(true);
        print("*** button Pressed " + vb.VirtualButtonName);
    }

    public void OnButtonReleased(VirtualButtonBehaviour vb)
    {
        ps.SetActive(false);
        star.SetActive(false);
        print("*** button Released " + vb.VirtualButtonName);
    }
    
    // Update is called once per frame
    void Update()
    {
        
    }
}