Hello,
I would like to know how to return the name of a button by clicking the mouse with a raycast.
Thanks in advance.
Hello,
I would like to know how to return the name of a button by clicking the mouse with a raycast.
Thanks in advance.
I found a response :
PointerEventData pointer = new PointerEventData(EventSystem.current);
pointer.position = Input.mousePosition;
List<RaycastResult> raycastResults = new List<RaycastResult>();
EventSystem.current.RaycastAll(pointer, raycastResults);
if(raycastResults.Count > 0)
{
/*if(raycastResults[0].gameObject.name == "Background")
print("You touched Background");*/
print("Object : " + raycastResults[0].gameObject.name);
}