private void MouseSelect()
{
RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(
Input.mousePosition), Vector2.zero);
// When the target layer is hit
if (hit.collider != null && hit.collider.gameObject == gameObject)
{
transform.localScale = new Vector3(1.2f, 1.2f, 1); // Enlarge the object
}
else
{
transform.localScale = new Vector3(1, 1, 1); // Restore the object's scale
}
if (Input.GetMouseButtonDown(0))
{
// Mouse button pressed while the target layer is hit
if (hit.collider != null && hit.collider.gameObject == gameObject)
{
}
}
}Unity - Enlarge an Object When the Mouse Hovers Over It
·76 words