Search Unity

Allow UI element to capture ray

Discussion in 'UGUI & TextMesh Pro' started by Slev, Nov 18, 2014.

  1. Slev

    Slev

    Joined:
    Sep 8, 2012
    Posts:
    148
    I'm using a setup where I use raycasts to select objects and then have UI popups for modifiers. The problem however is that the rays travel through the UI. Is there a method to absorb these rays? Do I need to do an event check to verify my mouse is not over a UI object or is there a way for the UI elements to block the ray collisions?
     
  2. RakshithAnand

    RakshithAnand

    Joined:
    Jun 30, 2013
    Posts:
    56
    You can add "Canvas Group" component to your UI canvas and set Block raycast to "false" temporarily so that UI wont respond to the raycast. But if this is not feasible, then maybe you can use layerMask to avoid raycasting the UI layer

    Also in "Graphic Raycaster" component, you can try checking blocking objects to all. Depends on your scenario
     
    Last edited: Nov 18, 2014