Skip to content

Instantly share code, notes, and snippets.

@danaabs
Created March 11, 2017 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danaabs/fde2e3a55ff000c453816a67c1c36e83 to your computer and use it in GitHub Desktop.
Save danaabs/fde2e3a55ff000c453816a67c1c36e83 to your computer and use it in GitHub Desktop.
Button Code for Food (unity)
public class PilsFood : MonoBehaviour, IVirtualButtonEventHandler {
private GameObject vbbuttonObject3;
//private GameObject showTest;
private GameObject BPils;
private GameObject BAle2;
private GameObject BPils2;
// Use this for initialization
void Start () {
vbbuttonObject3 = GameObject.Find ("PilsactionButton");
//zombie = GameObject.Find("zombie");
//showTest = GameObject.Find("SphereTest");
BPils = GameObject.Find ("BPilsner");
BAle2 = GameObject.Find ("BAle2");
BPils2 = GameObject.Find ("BPils2");
BAle2.SetActive (false); //hide B Ale @ start
vbbuttonObject3.GetComponent<VirtualButtonBehaviour> ().RegisterEventHandler (this);
}
public void OnButtonPressed(VirtualButtonAbstractBehaviour vb){
Debug.Log ("button down!!");
//zombie.GetComponent<Animation>().Play();
//showTest.SetActive(true);
BPils.SetActive (false); //hide BLager when button pressed
}
public void OnButtonReleased(VirtualButtonAbstractBehaviour vb){
BAle2.SetActive(true); //show BAle when button release
BPils2.SetActive(false);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment