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
0
Question by VideoJames · Jan 06, 2020 at 12:00 AM · raycastcanvas

Canvas Disabled but UI elements still block Raycasts

I have this hierarchy of Canvases Canvas_Parent
- UI Elements
- Canvas_Child
- - UI Elements
- Canvas_Child
- - UI Elements

In order to turn them all off at once I disable the Canvas Component on Canvas_Parent. However, the UI Elements under Canvas_Child continue to block Raycasts while the ones directly under Canvas_Parent do not.

Pretty Frustrating
All of the UI Elements within the hierarchy do not block Raycasts until the Canvas_Parent component is enabled for the first time

How can I ensure no UI ELements in that hierarchy block Raycasts when I disable Canvas_Parent component?

Note: I can't use SetActive on the gameobject to just close down the full hierarchy for performance reasons.

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

4 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Knights_user · Mar 09, 2020 at 11:23 AM

Try disabling "Graphic Raycaster" component on Canvas.

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 LOSTSOUL86 · Jan 06, 2020 at 05:08 AM

Hi maybe this can help. If you want to disable all children along with parent, I did by

 parent.setActive(false); 

And later to enable.

 parent.setActive(true); 

Then nothing is blocking raycast. In your case you disabling 1 canvas so other canvases are still active.

Maybe you should consider structure like:

popUpMenu (no canvas - just control script)

  • Menu1 (with canvas)
    • Menu2 (with canvas)

    • Menu3 (with canvas)

in control script you just put:

public GameObject menu1;

public GameObject menu2;

public GameObject menu3;

And then popUpMenu is always active to keep script active and to keep children accesible and depending on action you just do menu1.setActive(true).... menu2.setActive(false).... etc you can turn on or turn off any of them at any time.

Comment
Add comment · Show 3 · 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 VideoJames · Jan 06, 2020 at 05:19 AM 0
Share

Appreciate your answer, but I'm avoiding using gameobject.SetActive() as it is much worse for performance. Unity recommend disabling the component - in this article on UI performance at number 6 - rather than using SetActive.
I'll edit my question to include this bit of information since I missed it. Sorry about that.

avatar image LOSTSOUL86 · Jan 06, 2020 at 07:57 AM 0
Share

Hi. But it's still the same problem. Game objects can have game objects in child. But components do not have children. Switching off component in one game object does nothing to its children. Still you need to get reference to game objects. And then for example Canvas canvas1 = menu1.GetComponent<Canvas>(); And later canvas1.enabled = false; Do the same for menu2/canvas2 and menu3/canvas3 Components dont have children. You need to switch off component in every game object to achieve what you need.

avatar image VideoJames LOSTSOUL86 · Jan 06, 2020 at 07:30 PM 0
Share

Hi. I see, I misread your answer. I thought you were saying use SetActive on the parent gameobject in order to turn off the entire heirarchy.
I was hoping that there is some kind of parenting happening since the blocking doesn't happen until the first time I enable that parent canvas.
Storing a reference to each Canvas would technically work, but it isn't a route work want to take as it requires a major overhaul to the existing code base.

avatar image
0

Answer by AntonioPena · Mar 09, 2020 at 11:51 AM

hi, adding a CanvasGroup component to the Canvas_Parent and change property .BlocksRaycasts to false works for me. Remember to change this property to true when you activate the canvas component again.

hope it helps

Antonio

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 aoun111 · Mar 14, 2020 at 10:15 AM

Add a canvas group and disable the checks interactable and blocks raycast.

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

178 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image 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 on Canvas in a render texture 0 Answers

Trying to cast a ray towards a canvas but an invisible copy(?) of the canvas is blocking the way. 1 Answer

Can't interact with buttons in a UI Canvas in World Space Render Mode. 0 Answers

Help with Raycast on Render Texture 0 Answers

UI Buttons visible but not clickable when using two canvases. 3 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