- Home /
Override Sorting disables Blocks Raycasts
I have a list of DragHandler UI objects. Each of these objects has a Canvas Group component with Blocks Raycasts checked on. However, when dragging these objects in the scene, based on where it is instantiated within the list, it may either render above or behind other objects in the list.
The solution I thought would be to add a canvas component and then use the override sorting element on the object being dragged to sort it to the top. However, adding the canvas component turns off Blocks Raycasting for whatever reason. So I can't drag these objects within the scene. Does anyone know of a solution? There is similar issue reported, but that deals with a static element whereas I am dragging my object within the scene, so having a duplicate object doesn't work.
http://answers.unity3d.com/questions/856347/override-sorting-breaks-blocks-raycasts.html
Thanks.
I have similar problem. If I add Canvas component on gameobject, it just start to ignore all mouse (touch) event, even though Canvas component is disabled from the beginning of the scene load. Is this caused by Unity bug? Or do I need to know more about overring in Canvas component? Please help me if you know anything about this problem.
Thanks!
$$anonymous$$y issue was related to the sorting of draggable objects. To solve this, in my drag handler script, I created a startparent variable to remember the original parent (startParent = transform.parent;) of the object select to drag, then when I drag the object, I parent it to the canvas directly. This places it at the top layer for sorting within the canvas. When I end the drag and drop it in its new slot, I parent it back to it's startparent. The game object being dragged does have a canvas group associated with it, but I have all the desired functionality that I want. I never had an issue with touch events being ignored as $$anonymous$$e was more of a sorting issue.
I see. Unfortunately, I cannot solve my problem by your solution. I need both overriding sorting layer by Canvas component and consumption of mouse click (touch) event - meaning block raycast. Ty for your reply.
Answer by kobyle · Sep 15, 2015 at 02:58 PM
Just add the "GraphicRaycaster" component to you sub canvas gameobjects. this should fix it.
Koby
This answer is exactly the way how I solved. Thanks anyway!
Thank you! I can't believe that was what I was missing.
Your answer
Follow this Question
Related Questions
Click&Drag Misterious Disappearing! 1 Answer
GraphicRaycaster not detecting UI elements 0 Answers
Raycasting on render texture, minimap 1 Answer
Using Raycasting in AR to display UI 0 Answers