- Home /
Question by
RJJ92 · Mar 26, 2015 at 12:55 PM ·
destroyvuforiavirtual functions
How do I disable or Destroy Virtual Buttons using C#?
I've created a project and I want to be able to destroy the button after use. How do I go about it?
This is my code sample:
public class AnswerOne: MonoBehaviour, IVirtualButtonEventHandler {
void Start () {
VirtualButtonBehaviour[] vbs = transform.GetComponentsInChildren<VirtualButtonBehaviour> ();
for (int i=0; i < vbs.Length; ++i) {
vbs[i].RegisterEventHandler(this);
}
}
public void OnButtonPressed(VirtualButtonAbstractBehaviour vb){
if (vb.name == "1Q1") {
new WaitForSeconds(2);
carlight.SetActive(true);
}
}
public void OnButtonReleased(VirtualButtonAbstractBehaviour vb){
if (vb.name == "1Q1") {
print ("1A1released");
//Destroy Code here
}
}
}
Comment