Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by SioHio · Nov 21, 2015 at 12:33 AM · buttoncanvasraycastingphysics.raycasthitbox

Clickable object behind clickable HUD element with Unity UI

I have a clickable 3d object in the scene rendered by the main camera. The main camera has a PhysicsRaycaster attached and the object a normal box collider for example so its clickable as wanted.

Then I add a transparent HUD with a button for example which should be rendered always on top of normal 3d scene, so a HUD gameobject with a canvas which contains the button at some place on the screen.

My question is how do I setup the canvas so that I can click the button in the HUD but still are able to click the 3d object in the scene as well. Here are the ways I already tried:

  • Set Canvas to screen space overlay plus a GraphicsRaycaster next to the Canvas. The HUD is clickable but all clicks are intercepted by the GraphicRaycaster and never reach the PhysicsRaycaster of the main camera so the 3d object is not clickable anymore

  • Set Canvas to screen space camera, now the HUD neets to be placed very close to the main camera (canvas->plane distance) otherwise the UI is rendered behind the 3d objects. Placing the Canvas so close to the main camera will again block all rays to hit the 3d objects in the scene

  • So instead keeping the canvas->plane distance at a high distance but rendering the canvas with a separate camera on top of the main camera is the closest I got. The HUD is always on top of the 3D objects and both the HUD elements and the 3d objects are clickable excapt if a clickable 3d object is now physically in front of the HUD the 3d object is clicked and not the HUD element.

Its probably some stupid mistake by me but I can't figure out how to do this the right way :/

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by JoshuaMcKenzie · Nov 21, 2015 at 03:20 AM

there are a couple ways you can go about this. but the quickest and easiest way that I've found is to use canvasGroup components.

have a canvas group component on the Canvas that doesn't block raycasts. Then in a panel that has a button (or group of buttons) you want detected have another canvas group that blocks raycasts and ignores parent.

Comment
Add comment · 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
0

Answer by AmunTech · Nov 21, 2015 at 02:24 AM

have you tried to uncheck the raycast target checkbox on the images? I know that this can block mouse click on ui objects placed behind if its checked, but i dont know if its the same for 3d objects.

Comment
Add comment · 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

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

6 People are following this question.

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

Related Questions

How can I select a UI element with a raycast from another UI element? 2 Answers

Canvas: On hovering over Buttons: Wrong Buttons activated 2 Answers

If button highlighted 2 Answers

Problem with a button 2 Answers

Cannot click UI button. 4 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