Inuyasha123
Topic Author
Posts: 19
Joined: 22 May 2019, 10:53

Unity3D cannot use the mouse click control when displaying multiple screens

25 Nov 2019, 10:02

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.
 
User avatar
jsantos
Site Admin
Posts: 3925
Joined: 20 Jan 2012, 17:18
Contact:

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

28 Nov 2019, 17:20

Could you please open a ticket about this? Thanks!
 
Inuyasha123
Topic Author
Posts: 19
Joined: 22 May 2019, 10:53

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

02 Dec 2019, 09:28

Yes, I will
 
User avatar
jsantos
Site Admin
Posts: 3925
Joined: 20 Jan 2012, 17:18
Contact:

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

02 Dec 2019, 16:18

Thank you!
 
cpatino2
Posts: 1
Joined: 29 Sep 2023, 02:32

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

29 Sep 2023, 02:34

@
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
 
User avatar
jsantos
Site Admin
Posts: 3925
Joined: 20 Jan 2012, 17:18
Contact:

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

29 Sep 2023, 11:13

This was never reported in the tracker, could you please file a ticket about it? Thank you

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 43 guests