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: 2609
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: 2609
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!

Who is online

Users browsing this forum: No registered users and 10 guests