Hi all,
I’m working on a menu which is brought up by holding down the mouse, and the player selects an element by releasing the mouse button while hovering over a certain element. Right now each element in the menu is an Image on a canvas. Each image has an instance of a script which has the following snippet of code:
private void OnDisable()
{
if (EventSystem.current.IsPointerOverGameObject())
{
print(this.name + " selected");
}
}
However, when I test this in Unity every single instance of the script responds and prints its name (even though clearly the mouse can only be in one spot at a time). Is using IsPointerOverGameObject() the wrong approach to this problem? Or am I doing something wrong?
Many thanks!