Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Physic Raycaster on UI : Issue since 5.1.0f3

Discussion in 'UGUI & TextMesh Pro' started by BenouKat, Jun 11, 2015.

  1. BenouKat

    BenouKat

    Joined:
    Feb 29, 2012
    Posts:
    222
    Hi there,

    I'm facing issue with Physics Raycaster. I'm actually using the OnDrag event on an object. I put a layer on this object and put only this layer on the Physics Raycaster mask of my camera.

    In 5.0 the raycaster ignored the UI and it was all good.
    Now in the 5.1, the PointerCurrentRaycast tells me that he hits UI element (a button)

    Someone is facing the same issue ? Is something changed about raycasters ?

    I had to replace every PointerEventData.worldPosition by PointerEventData.pointerCurrentRaycast.worldposition, because the first one give me 0,0,0 since update.

    Thanks a lot !
     
    Last edited: Jun 11, 2015
  2. Gaspar

    Gaspar

    Joined:
    Jun 14, 2014
    Posts:
    28
    Hi,
    just faced problem with this raycast and it was fixed after i added checking for
    if (eventData.pointerCurrentRaycast.isValid)

    Looks like unity not always make raycast. May be it will help you.
     
  3. Andy-Lee

    Andy-Lee

    Joined:
    Aug 16, 2014
    Posts:
    26
    Yes, we have the same problem too after updating Unity.
    Simply adding "if (eventData.pointerCurrentRaycast.isValid)" doesn't fix it.
    I have to also check "if (eventData.pointerCurrentRaycast.distance > 0)".

    However, the result is changed a little bit. Lets say we use the world position of event data to do camera dragging in our mobile game. Before the update, camera can still be dragged even if the touch moves onto UI. But now, we can no longer calculate the position delta and hence cannot move camera. Though this isn't something unacceptable, we prefer the original behaviour, that is, pointerCurrentRaycast can ignore UI.

    In fact, we have a PhysicsRaycaster on the camera with the appropriate layer mask selected. The UI layer is excluded. So, shouldn't raycast ignore UI layer? :confused:
     
  4. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    Could you give us a bug report Andy?
     
  5. jhkimblue

    jhkimblue

    Joined:
    Mar 27, 2015
    Posts:
    14
    I reported that (Case 707026).
    and i've got a answer from Tim C, it has been fixed at 5.3.
    But seriously, 5.3? it's december. i've already suffered these kind of raycast issues almost half of a year.
     
  6. Andy-Lee

    Andy-Lee

    Joined:
    Aug 16, 2014
    Posts:
    26
    Thanks jhkimblue. I hope I have the time to report that but we have a very tight schedule right now.
    What about Unity 4? We are using 4.6.8p1.