Search Unity

Physics raycaster and multiple display

Discussion in 'UGUI & TextMesh Pro' started by Driiade, Apr 18, 2018.

  1. Driiade

    Driiade

    Joined:
    Nov 21, 2017
    Posts:
    80
    Seems like the physics raycaster doesn t want to work with multiple display with one physics raycaster on each camera.

    Works great on editor but not in build.

    However UI element work great on build but have bugs on editor ( bad position when the window is not focused)


    Someone has a solution ?
     
  2. Driiade

    Driiade

    Joined:
    Nov 21, 2017
    Posts:
    80
    Hummm there is a very important bug.

    Eventdata.position is not well set with multiple screen ( don t begin at x = 0 on the left of secondaries screen ) .

    I hotfixed this with a Display.RelativeMouseAt(Input.mousePosition)

    But it only work on build.
     
    Last edited: Apr 18, 2018
  3. Driiades

    Driiades

    Joined:
    Oct 27, 2015
    Posts:
    151
    Code (CSharp):
    1.             var eventPosition = Display.RelativeMouseAt(eventData.position);
    2.             if (eventPosition != Vector3.zero)
    3.             {
    4.                 // We support multiple display and display identification based on event position.
    5.  
    6.                 int eventDisplayIndex = (int)eventPosition.z;
    7.  
    8.                 // Discard events that are not part of this display so the user does not interact with multiple displays at once.
    9.                 if (eventDisplayIndex != displayIndex)
    10.                     return;
    11.             }
    12.             else
    13.             {
    14.                 // The multiple display system is not supported on all platforms, when it is not supported the returned position
    15.                 // will be all zeros so when the returned index is 0 we will default to the event data to be safe.
    16.                 eventPosition = eventData.position;
    17.  
    18.                 // We dont really know in which display the event occured. We will process the event assuming it occured in our display.
    19.             }
    Is in GraphicsRaycaster but not in PhysicsRaycaster.

    Someone from unity can repair ? :D