I’m trying to find a way to know if the pointer from the pointer event data is being pressed but I’m failing to find a variable in the class to tell if it’s pressed or not!
“clickCount” doesn’t resets to 0 if there is no click count and even if it did it’s not what I want, I want the exactly current state of the pointer, if it is pressed or not!
Also, there is not a single documentation on “eligibleForClick”.
Is this something you need to get from the pointer event data? If your pointer is tied to the mouse you could use Input.GetMouseButton.
1 Like
I was doing GetMouseDown, yes, it works, but since it’s going to be for touch screen devices I’m afraid something goes wrong.
It seems like eligibleForClick is what I want, and there is no documentation about it, but it seems to return true when the pointer is being pressed and false otherwise.
But I just found that OnPointerUp won’t be called if I begin my click on nothing (no objects to intersect the event, just the plain canvas).
public class ExampleClass: MonoBehaviour, IPointerDownHandler, IPointerUpHandler
{
bool isDown;
public void OnPointerDown(PointerEventData eventData)
{
isDown = true; //this void is called when the pointed started baing pressed at this UI image, and the raycast is enabled in the Image Component
}
public void OnPointerUp(PointerEventData eventData)
{
isDown = false; //this void is called even if the pointed stopped being pressed somewhere else
}
void Update()
{
print(isDown);
}
}