Reputation: 1
I want to add a click event on my gameObject, but it won't work, I don't know why it don't work on gameObject, but it work on the test button. I don't know why. Can anybody help me with it. This is the click code:
public void cardsClick()
{
Debug.Log("aa");
}
And this is how I add click event to game object
Upvotes: 0
Views: 762
Reputation: 57
I'm not sure where you add the button script. However make sure you add it to Buttton not to Canvas.
If you add it correctly I can guess you make this cards inactive before. Then you turn it to active. In this situation Unity is bugged and buttons stop work. Try Button.Interactable instead.
Also if I'm not right try to add target Graphics, because Unity can don't know where is the button.
I don't have more ideas what could went wrong, but I hope I help you.
Upvotes: 0