I have this 2D button set up and I've added a 2D circle collider to it. And I've added the following script.
public UnityEvent upEvent;
public UnityEvent downEvent;
public void onm ouseDown() {
Debug.Log("Down");
print("down");
downEvent?.Invoke();
}
public void onm ouseUp() {
Debug.Log("Up");
upEvent?.Invoke();
}
but when I click on this button, nothing happens. I don't get any errors. Nor do I see any Debug message or see the events get called.
CodePudding user response:
Based on the documentation:
This function is not called on objects that belong to Ignore Raycast layer.
This function is called on Colliders marked as Trigger if and only if Physics.queriesHitTriggers is true.
Check that your collider is marked as trigger and that the queriesHitTriggers
is true.
CodePudding user response:
It's possible that you have another UI object that's blocking it. For example, an invisible panel that's also a raycast target that is in front of the button may be blocking the click interaction from occuring.