If you set up an edge collider on the objects you can use
void Update()
{
//this detects the mouse position
Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
//this check to see if the mouse is over the collider documentation below
if (this.GetComponent<EdgeCollider2D>().ClosestPoint(mousePos) == mousePos)
{
print("mouse is hovering over object");
if
{
}
}
}
documentation https://docs.unity3d.com/ScriptReference/Collider.ClosestPoint.html