Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by nviro · Apr 30, 2015 at 07:44 AM · raycastcanvasdragsorting

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.

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image comworm · Jul 16, 2015 at 09:43 AM 0
Share

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!

avatar image nviro · Jul 16, 2015 at 11:41 AM 0
Share

$$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.

avatar image comworm · Jul 17, 2015 at 01:21 AM 0
Share

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.

1 Reply

· Add your reply
  • Sort: 
avatar image
24

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

Comment
Add comment · Show 6 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Horothenic · Oct 26, 2016 at 11:51 PM 0
Share

You are a hero! Thank you very much

avatar image comworm · Oct 27, 2016 at 01:15 AM 0
Share

This answer is exactly the way how I solved. Thanks anyway!

avatar image drHogan · Nov 15, 2016 at 09:02 AM 0
Share

$$anonymous$$oby, savior of the day.

avatar image farazahmad759 · Apr 19, 2018 at 08:18 PM 0
Share

Thank you $$anonymous$$oby :)

avatar image xKittenCatx · Jul 15, 2021 at 11:50 PM 0
Share

Thank you! I can't believe that was what I was missing.

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Click&Drag Misterious Disappearing! 1 Answer

GraphicRaycaster not detecting UI elements 0 Answers

Raycasting on render texture, minimap 1 Answer

Detect when UI element in canvas overlaps with moving game object and then make element follow object 0 Answers

Using Raycasting in AR to display UI 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges