Vector3 viewMouse = Cam.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, -Cam.transform.position.z)); Vector3 viewPos = Cam.WorldToViewportPoint(viewMouse); if (viewPos != null && viewPos.x >= 0 && viewPos.x = 0 && viewPos.y 0) { } else { return null; }