Search Unity

4.6.1 - issues with physics and graphics raycasters in same scene.

Discussion in 'UGUI & TextMesh Pro' started by holyjewsus, Jan 17, 2015.

  1. holyjewsus

    holyjewsus

    Joined:
    Mar 7, 2011
    Posts:
    624
    I have a physics ray caster on my camera, and I have a screen space overlay UI.

    edit: slight clarification, my screen space overlay UI has it's own graphics ray caster.

    If a game object is behind any part of my UI, it seems to intercept the event and I cannot interact with the UI buttons, for instance cannot click or hover. My intention is for the 2d ui element to receive the click and hover events since they are in front of the game object... I'm unclear how physics ray casters and graphics casters should work together.

    Hints?
     
    Last edited: Jan 17, 2015
  2. holyjewsus

    holyjewsus

    Joined:
    Mar 7, 2011
    Posts:
    624
    more info- if I turn the physics ray caster off, then I get the events on the screen space UI, and this worked correctly in 4.6
     
  3. holyjewsus

    holyjewsus

    Joined:
    Mar 7, 2011
    Posts:
    624
  4. Chris-de-Castro

    Chris-de-Castro

    Joined:
    Oct 16, 2014
    Posts:
    11
    I'm getting the same problem and setting the blocking objects in the screen space canvas doesn't work.
    I've got world space canvases attached to game objects, a physics ray caster to make world objects click/tap'able and a screen space canvas with buttons.
    The screen space buttons don't work unless i turn off the graphics ray caster (while in runtime). Weird thing is that the world space canvas buttons always work whether or not the physics ray caster is working.

    Tried switching around the Blocking Objects, Blocking Mask, Physics Raycaster Event Mask and the Canvases Layer Mask.

    One workaround I was trying was to disable the Physics Raycaster when I enabled the screen space canvas but I can't seem to find it with Main Camera -> GetComponent<PhysicsRaycaster>().SetActive = false

    Weird.
     
  5. Chris-de-Castro

    Chris-de-Castro

    Joined:
    Oct 16, 2014
    Posts:
    11
    installed 4.6.1p4... FIXED!
    THANK YOU UNITY!
     
  6. VipHaLongPro

    VipHaLongPro

    Joined:
    Mar 8, 2015
    Posts:
    49
    Not sure if 4.6.1p4 fixed this issue. But from the patch release notes, looks like it does not mention any thing related to this issue. Although this issue is fairly serious I think.

    BTW, I don't understand what kind of patch it is when its size is as nearly as the Unity's size (more than 1GB) (of the same version)? I thought it was just about several to maximum of 50 MB?
     
  7. VipHaLongPro

    VipHaLongPro

    Joined:
    Mar 8, 2015
    Posts:
    49
    Because of the patch's big size (more than 1GB). I did not want to download that patch to test fixing this issue. However fortunately that I've managed myself to find a simple fix. So I'm going to post it here and maybe it will help some other.
    To fix this issue (don't need any patch), you can just uncheck the Default layer from Event Mask property of the Physics Raycaster component. You may have to avoid using the Default layer and create any replacing that layer of course.

    There is another issue related here is when mouse hovering some UI element, it can still trigger events on any 3D object behind that UI element. Well I'm not sure if there is any patch fixing this but we can have some simple workaround with this issue using some kind of flag.
     
    Last edited: Apr 22, 2015