using UnityEngine; public class TekkenVirtualButtonEventHandler : MonoBehaviour, IVirtualButtonEventHandler { // Private fields to store the models private GameObject _modelJin; private GameObject _modelYoshimitsu; /// /// Called when the scene is loaded /// void Start() { // Search for all Children from this ImageTarget with type VirtualButtonBehaviour VirtualButtonBehaviour[] vbs = GetComponentsInChildren(); for (int i = 0; i < vbs.Length; ++i) { // Register with the virtual buttons TrackableBehaviour vbs[i].RegisterEventHandler(this); } // Find the models based on the names in the Hierarchy _modelJin = transform.FindChild("jin1u").gameObject; _modelYoshimitsu = transform.FindChild("yosi1u").gameObject; // We don't want to show Jin during the startup _modelJin.SetActive(false); } /// /// Called when the virtual button has just been pressed: /// public void OnButtonPressed(VirtualButtonAbstractBehaviour vb) { switch(vb.VirtualButtonName) { case "btnYoshimitsu": _modelJin.SetActive(false); _modelYoshimitsu.SetActive(true); break; case "btnJin": _modelJin.SetActive(true); _modelYoshimitsu.SetActive(false); break; default: throw new UnityException("Button not supported: " + vb.VirtualButtonName); break; } } /// /// Called when the virtual button has just been released: /// public void OnButtonReleased(VirtualButtonAbstractBehaviour vb) { } }