Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Multiple camera with multiple canvas UI Button Event Problem

Discussion in 'Immediate Mode GUI (IMGUI)' started by ASIM-SENYUVA, Sep 19, 2019.

  1. ASIM-SENYUVA

    ASIM-SENYUVA

    Joined:
    Apr 29, 2013
    Posts:
    90
    Hello,

    I have multiple cameras in one scene. The scene also has 2 UI ( Canvas). Each canvas has screen space overlay and refers to related displays. When playing the scene Eventtrigger detects the smallest short order canvas events on the other hand when I move to my mouse to monitor related event effects to another monitor. For example. I click monitor 2 but monitor 1 effected.

    I try
    • Put different layers to each canvas and try to block other canvas with graphic raycaster but it not solves.
    • I un-checked raycast target over Image and other not an event-related object for reducing intersections but it not solved.
    • The scene has only one EventSystem. EventSystem refers to the main screen because of this i try to set Canvas Render mode to ScreenSpace and put culling mask for the hide to not related UI and others but the camera shows black
    • I try to camera depts but it is not solved
    How can i solve this problem? any suggestion?

    Canvas 1

    upload_2019-9-19_22-20-15.png

    Canvas 2

    upload_2019-9-19_22-20-46.png

    Camera 1
    upload_2019-9-19_22-30-39.png


    Camera 2
    upload_2019-9-19_22-31-10.png

    problem here :


    upload_2019-9-19_22-29-9.png
     
  2. ASIM-SENYUVA

    ASIM-SENYUVA

    Joined:
    Apr 29, 2013
    Posts:
    90
    Another ScreenShot,
    When i disable Graphic Raycaster its block events also. In this case a simple but bad workaround when i click windows 1 disable windows 2 raycaster and click windows 2 disable windows 1 graphic raycaster but i do not like this solution.
    still search during 5 hour...

    upload_2019-9-19_23-16-20.png
     
    WRG55 likes this.
  3. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,137
    josephphilleo and ASIM-SENYUVA like this.
  4. ASIM-SENYUVA

    ASIM-SENYUVA

    Joined:
    Apr 29, 2013
    Posts:
    90
    Resolved, Thank you for the information during more than 5 hours I learn deep things about Canvas and UI. It's working on build time. :)
     
    karl_jones likes this.
  5. tms_dev

    tms_dev

    Joined:
    Nov 26, 2018
    Posts:
    47
    What did you learn? It would be nice if you shared for people having the same problem T_T
     
  6. ASIM-SENYUVA

    ASIM-SENYUVA

    Joined:
    Apr 29, 2013
    Posts:
    90
    It works on build time, no need to confuse at the editor. It calculated exact dimensions at runtime.
     
  7. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    856
    I don't see how that is a solution. Do you build everytime you need to test any interaction? I have encountered this issue a number of times over the past years to much frustration.

    Was this never fixed @karl_jones?
     
  8. ASIM-SENYUVA

    ASIM-SENYUVA

    Joined:
    Apr 29, 2013
    Posts:
    90
    The problem only comes at Editor. There is no solution for the editor. On the other hand, there is no problem with Build Time
     
  9. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    856
    Which means you "only" have to build everytime you need to test any minor UI interaction. Such a pain.
     
  10. ASIM-SENYUVA

    ASIM-SENYUVA

    Joined:
    Apr 29, 2013
    Posts:
    90
    You are exactly true. Especially during software tests, there can be a lot of problems. I usually test with keyboard shortcuts when problems arise.
     
  11. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    856
    I am now using this hack together with ICanvasRayCastFilter to extend UI and achive correct multi display behaviour in the Editor. I suspect this will only work on Windows.

    Code (CSharp):
    1. [DllImport( "user32.dll" )]
    2. [return: MarshalAs( UnmanagedType.Bool )]
    3. private static extern bool GetCursorPos( out MousePosition mp );
    4.  
    5. [StructLayout( LayoutKind.Sequential )]
    6. public struct MousePosition
    7. {
    8.     public int x, y;
    9. }
    10.  
    11. public static bool IsMouseOverMainDisplay()
    12. {
    13.     Display mainDisplay = Display.main;
    14.     MousePosition mp;
    15.     GetCursorPos( out mp );
    16.  
    17.     return mp.x > 0 && mp.y > 0 && mp.x < mainDisplay.systemWidth && mp.y < mainDisplay.systemHeight;
    18. }
     
  12. ASIM-SENYUVA

    ASIM-SENYUVA

    Joined:
    Apr 29, 2013
    Posts:
    90
    Yes its windows dependent because of win API (user32.dll)
     
  13. Coloradete

    Coloradete

    Joined:
    Sep 23, 2019
    Posts:
    4
    Hello! I'm using version 2021.3.0f1 and having the same problem on build time, when I click on UI buttons on the display 2 the buttons on display 1 (in the exact same position) gets triggered. I have the canvas set to Screen Space - Camera as I'm rendering four cameras per display each of them with their own UI. Any workaround for this?
     
  14. jeepee-ef

    jeepee-ef

    Joined:
    Jul 20, 2018
    Posts:
    11
    Same here (Unity2022.3.14f1) unfortunately, is there a bugreport for this already? Or is there something to do to prevent this?