Detect when Input.GetMouseButton() is not on a GuiButton
Hi, I have a two gameObject "MovingObject" and "Receptor" that are supposed to collide and a GuiButton "GuiButton". When the MovingObjectCollide and the Receptor and the player "clicks" or touches the screen I want to apply some code. The only condition is that the click/touch should not be on the "GuiButton".
I've done so far: Script attached to "MovingObject"
private void OnTriggerStay2D(Collider2D col)
{
if (col.gameObject.tag == "Receptor")
{
if (Input.GetMouseButtonDown(0) && GetObjectClickedOn() != "InGameButton") // We verify that we are not in fact clicking on a game button
{
//Apply some code
}
}
}
The GuiButton have a proper OnClick Event that raises some other code:
public void OnClickGuiButton(){
//apply specific GuiButton Code
}
When MovingObject and Receptor are collided, a click will work only if it outside GuiButton, otherwise apply GuiButton code only.
I implemented GetObjectClickedOn() of the moving object with an OverlapPoint/CirclePoind... around the Input.MousePosition but it doesn't detects the GuitButton when clicked on.
Any idea how to solve it ? Thanks