Hello,
I am trying to detect when my mouse is passing over a button ( not using the mouse over feature ) . I have created buttons in the canvas, and put box collider around each of them. I have put the camera frame to fit exactly the canvas whatever the screen size is :
camera.transform.position = new Vector3(Screen.width / 2, Screen.height / 2, -1000);
then I detect the collision between the camera hit and the buttons collider :
Ray camRay = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
// Perform the raycast and if it hits something on the floor layer…
if (Physics.Raycast(camRay, out hit, camRayLength, floorMask))
{
if (name == hit.collider.gameObject.name)
{
// doThings
It work perfectly on my game editor. HOWEVER, if i build it and run it as a standalone (full screen or windowed ) it does not work, the mouse input is shifted . Wat can be the reason ???
Thank you