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. Dismiss Notice

Physics2D Raycaster + Screen Space Overlay Issue - Please Help!

Discussion in 'UGUI & TextMesh Pro' started by MrDOfTheBay, Jan 31, 2015.

  1. MrDOfTheBay

    MrDOfTheBay

    Joined:
    Jan 31, 2015
    Posts:
    2
    Hi all,

    Having a fairly fundamental lack of smarts here. I've made a brand new project with just a Canvas and a 2D sprite to demonstrate my problem (attached).

    You'll notice if you "mouse over" the button, the left hand responds and turns yellow, but the right half does not. This is because I have placed a 2D box collider in the scene at this location. The intention (I thought) was that my box collider would receive events if the UI wasn't in the way, but it seems to be doing the opposite!

    The 2D Physics Raycaster is attached to the main camera, as recommended in docs.

    Things are certainly drawn in the correct order, with the button on top, but I cannot seem to figure out how to receive the events in the correct order. I have fiddled with canvas sort orders, sprite sorting layers etc. No matter what I do, my 2D Box Collider blocks the UI.

    Running 4.6.1f1 here.

    Any help would be much appreciated, I have lost a couple hours on google to this and I am well and truly stuck. Is this a bug in Unity? Or am I doing something immensely stupid?
     

    Attached Files:

  2. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,683
    There is a known issue with the draw order / raycast order with the UI at present. Still not fixed in 4.6.2.
    If you search there are a few posts already on the subject
     
  3. MrDOfTheBay

    MrDOfTheBay

    Joined:
    Jan 31, 2015
    Posts:
    2
    Hi Simon,

    Thanks for the feedback. I tried a couple of things from the following thread, but was not able to get them working:
    http://forum.unity3d.com/threads/graphic-raycaster-used-to-have-a-priority.283851/

    In the end I swapped my SS-Overlay canvas for a SS-Camera one and set up a second camera to render my UI (initially I tried using the same camera but my UI was lagging slightly behind the camera for some reason). Bit of hoop jumping but it all seems to be working as expected now.

    Hopefully the Unity guys can sort out the SS-Overlay mode because it seems a much simpler approach if it worked.

    Cheers,
    Ross.
     
    SimonDarksideJ likes this.
  4. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    Try 4.6.2p1 this is where the ordering fixes have been put. Sorry for the delay :(
     
  5. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,683
    Thanks for the update @phil-Unity , will check the release notes. However already seen that 4.6.2 hasn't fully fixed the ordering issue and causes some weird anchor issues in other posts
     
  6. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    yea 4.6.2 didn't have any fixes from UI :( but wait for the patch release should be out soon
     
  7. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,683
    Thanks for the Update @phil-Unity Will keep an eye out for the patch release.
    Hopefully it'll fix the canvas layout issues that has bee plaguing everyone in 4.6.2
     
  8. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    i havn't been following the forums as close as i should, which canvas layout issues?
     
  9. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,683
  10. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    perfect :) less work for me!
     
  11. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,683
    You should know by now @phil-Unity , there is no such thing :D
     
  12. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    I was pretending till someone burst my bubble :(
     
  13. SimonDarksideJ

    SimonDarksideJ

    Joined:
    Jul 3, 2012
    Posts:
    1,683
    We can all dream Phil o_O