Answers for "unity Check if mouse clicked UI element"

C#
3

unity check when clicked on object

void Update()
{
  // Check for mouse input
  if (Input.GetMouseButton(0))
  {
  	Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
   	RaycastHit hit;
   	// Casts the ray and get the first game object hit
   	Physics.Raycast(ray, out hit);
   	Debug.Log("This hit at " + hit.point );
  }
}
Posted by: Guest on March-27-2020
0

unity Check if mouse clicked UI element

EventSystem.current.IsPointerOverGameObject()
Posted by: Guest on August-04-2020

Code answers related to "unity Check if mouse clicked UI element"

C# Answers by Framework

Browse Popular Code Answers by Language