Page 1 of 1

Unity3D cannot use the mouse click control when displaying multiple screens

Posted: 25 Nov 2019, 10:02
by Inuyasha123
When Unity is running on multiple screens, I can't hit the control with the mouse, so I added the following code under NoesisView.cs. Sorry, I changed the code.
Because Unity will display these screens as a whole when displaying multiple screens at the same time, your mouse coordinates are the coordinates in this large screen.
 
private float offset;

void Start()
{
     offset = MultiScreenPosition();
}

public float MultiScreenPosition()
{
    float offset = 0.0f;
#if !UNITY_EDITOR
    int targetDisplay = _myCamera.targetDisplay;
    for (int i = 0; i < targetDisplay; i++)
    {
        Display display = Display.displays[i];
        if (display != null)
        {
            offset += display.renderingWidth;        
        }
    }
#endif
    return offset;
}
If I want to click on the control, I will do the following operation
_mousePos = UnityEngine.Input.mousePosition;
_mousePos.x -= offset;
UnityEngine.Vector2 mouse = ProjectPointer(_mousePos.x, _mousePos.y);
If the runtime changes the value of Camera's targetDisplay, the offset becomes the wrong value.

Re: Unity3D cannot use the mouse click control when displaying multiple screens

Posted: 28 Nov 2019, 17:20
by jsantos
Could you please open a ticket about this? Thanks!

Re: Unity3D cannot use the mouse click control when displaying multiple screens

Posted: 02 Dec 2019, 09:28
by Inuyasha123
Yes, I will

Re: Unity3D cannot use the mouse click control when displaying multiple screens

Posted: 02 Dec 2019, 16:18
by jsantos
Thank you!

Re: Unity3D cannot use the mouse click control when displaying multiple screens

Posted: 29 Sep 2023, 02:34
by cpatino2
@
Thank you!
At the end what happened with this one, we are in the same boat.

With different resolutions the hover Events and click events are not working properly

Re: Unity3D cannot use the mouse click control when displaying multiple screens

Posted: 29 Sep 2023, 11:13
by jsantos
This was never reported in the tracker, could you please file a ticket about it? Thank you