I have been using Unity’s UI buttons to make a clickable object. I gave it a function.
–snip–
public void Click(){
if (clickcount == 0) {
clickd = true;
clickcount += 1;
}
–snip–
This function links to this other function in the same object:
–snip–
void OnTriggerStay2D(Collider2D other){
if (clickd && other.gameObject.CompareTag ("touchable")) {
other.gameObject.GetComponent<CowRules> ().DEATH ();
}
}
–snip–
then the DEATH() part sets clickcount to 0 and clickd to false.
But then, when I clicked the button twice or more, the button’s script executes twice and sets clickd to true twice.
How do I fix this? Thanks.