A naive raycast problem solution for people who are tired enough.

*Notice. it may not fit with you’re case. i’m not a unity guy who has responsible for write right code for everyone. but you could get a idea from my solution. :slight_smile: And sorry about my poor grammar, I’m not a native. :stuck_out_tongue:

First of all, I’m tired with waiting a patch to solve this. This raycaster problem is existed since the first version of unity 5 until now. And It was too painful to hard-code workarounds case-by-case. So i finally open the ugui project which is open project at bitbucket. I changed just a line of code, and it worked nicely.

  1. I used 5.2.0 version for this solution. go get a project at here
    https://bitbucket.org/Unity-Technologies/ui/downloads

  2. GraphicRaycaster.cs Line 181.

sortingLayer =  canvas.cachedSortingLayerValue,

Change this code to

sortingLayer =  canvas.sortingLayerID,

this.

And you’re done. Just build dlls and put its in a installation folder as instructed here.
A line of code change will resolve most of raycaster issue.
https://bitbucket.org/Unity-Technologies/ui/overview

ps1. in my view, the evil of root for this problem is EventSystem.RaycastComparer() and Raycasters. if you face another raycast problems, take a look those classes.
ps2. if you’re facing a compile problem at editor when you try to bulid, restart your editor it’d resolve many issues. :slight_smile:

according to my repo tracking this exact fix was done in 5.2.1p1

thanks for your info. and please make a good patch note next time since i couldn’t find any note about it. :slight_smile:

Wasn’t me who added it so not sure why it wasn’t included in the patch notes. :frowning:

Which issue exactly is this about? I’m in 5.2.1.f1 and still having issues with raycasters when used with world-space canvases and perspective cameras. I submitted a bug report with code to fix the issue (raycasters using Raycast instead of GetRayIntersection) a few weeks ago, but it was never turned into an Issue.

it’s about when you use multi canvases with multi sorting layers.

5.1.1f1 is older than 5.2.1p1.

RE Patch notes: It looks like they didn’t get copied from our patch note staging area to our public release notes. I’ve notified someone about this.