I would like to get an invisible, clickable area on the screen attached to a canvas. How do I go about this?
Add invisible image to the button image and place button anywhere in the canvas.Now call function on button click .Like
public void show()
{
print(“clicked”);
}
Good day @IndiaVenom !
There are multiple ways to get that, i explain 2 solutions for this (but there are more for sure):
1- If this invisible area is the only clikable thing in this canvas , make the Canvas Render “Screen Space - Camera” in the Inspector. This way, the canvas is in front of the camera. SO now, you can create a Collider in the canvas that will detect when you click it with the method OnMouseDown() .
2- The second way is to detect the mouse position in he screen. This way you can do a if to determninate wich area of the screen are you interested.
int ScreenMaxX = Screen.height;
int ScreenMaxY = Screen.width;
if (Input.mousePosition.x > ScreenMaxX / 4 && Input.mousePosition.x < 3 * ScreenMaxX / 4 )
{
if (Input.GetMouseButtonDown(0)
{
//Do things
}
}
If this helps, Upvote and Check answer !
If need mroe help, just ask using @tormentoarmagedoom !
Bye :D!