Skip to content

Instantly share code, notes, and snippets.

@smallrice45
Created March 29, 2014 20:31
Show Gist options
  • Save smallrice45/9862374 to your computer and use it in GitHub Desktop.
Save smallrice45/9862374 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class ButtonEvent : MonoBehaviour , IVirtualButtonEventHandler{
// Use this for initialization
void Start () {
VirtualButtonBehaviour[] btn = transform.GetComponentsInChildren<VirtualButtonBehaviour>();
foreach(VirtualButtonBehaviour btns in btn)
{
btns.RegisterEventHandler(this);
}
}
public void OnButtonPressed(VirtualButtonAbstractBehaviour vb)
{
print ("Press");
if (vb.name == "VirtualButton1")
{
print ("PressVirtualButton1");
}
if (vb.name == "VirtualButton2")
{
print ("PressVirtualButton2");
}
if (vb.name == "VirtualButton3")
{
print ("PressVirtualButton3");
}
}
public void OnButtonReleased(VirtualButtonAbstractBehaviour vb)
{
print ("Released");
if (vb.name == "VirtualButton1")
{
print ("ReleasedVirtualButton1");
}
if (vb.name == "VirtualButton2")
{
print ("ReleasedVirtualButton2");
}
if (vb.name == "VirtualButton3")
{
print ("ReleasedVirtualButton3");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment