• 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 /
This question was closed Nov 20, 2015 at 05:14 AM by jRocket for the following reason:

The question is answered, right answer was accepted

avatar image
Question by jRocket · Nov 18, 2015 at 09:50 PM · unity 5user interface

UI Click pass through

I am making a context menu and when t$$anonymous$$s menu is called up I have an invisible panel in front of everyt$$anonymous$$ng except t$$anonymous$$s menu. I have a click handler on t$$anonymous$$s invisible panel. Right now, the invisible panel is getting the clicks and eating them(blocking them). What I would like it to is handle the event, but not block it, so the rest of the UI can get clicks as well.

If I turn off "Raycast Target" on the invisible panel's Image component, clicks go through, but they do not get handled.

Is there a way to have a UI element get handled but not block other elements?

Comment
cloutiertyler

People who like this

1 Show 5
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 ian_sorbello · Nov 19, 2015 at 04:45 AM 0
Share

I can't think of a way to bubble the event further - so I'd be inclined to get creative...

You can fire your own ray through the screen, and assuming your UI is added to the appropriate layer - you can get a handle to all the UI elements you "touch".

Then handle each one independently. The only issue though is that this does not use the UI message system, so sounds clunky...

avatar image Le-Pampelmuse · Nov 19, 2015 at 05:13 AM 1
Share

Why do you need a transparent panel to get clicks but not block them? That's kind of contraproductive. ;)
Wouldn't it be easier to simply check if the the mouse is clicked & the context menu is not clicked? Because this means logically, that anything in the "background" is clicked. Example code:

 if(click & click.tag != "ContextMenu")
 {
     CloseMenu();
 }

Using Tags is just one simple way to give you an example.

Additionally I's like to mention, that this is a "HowToDo" question for Unity Forums, not for Unity Answers.
Unity Answers is for problems with Unity functions that behave unexpected.
Check out the Frequently Asked Questions and the User Guide to avoid this in the future.

Is there a way to have a UI element get handled but not block other elements?

This would the question you should google or search Unity Forums for.
Google might point you to Unity Forums anyway :)

Have a nice day.

avatar image jRocket Le-Pampelmuse · Nov 19, 2015 at 02:00 PM 0
Share

Yes, but I need somewhere to see what's been clicked. If I just use something like Input.GetMouseButtonDown, that won't do a ray cast to see what's been hit.

I suppose I could use something like ian_sorbello's answer and do my own ray cast.

avatar image jRocket jRocket · Nov 19, 2015 at 02:45 PM 0
Share

I was able to get it working as I wanted by checking for Input.GetMouseButtonUp in the Update loop- and then destroying the object no matter what is hit. Because Desroy is delayed, any buttons hit on the menu will still execute.

Show more comments

1 Reply

  • Sort: 
avatar image

Answer by jkramar · Nov 19, 2015 at 02:34 PM

Have a look at the CanvasGroup Component. It has at least part of the functionality you are looking for.

Comment
dazapa2894

People who like this

1 Show 0 · 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

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

41 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

Related Questions

Send inputfield entries via email 2 Answers

From an optimization point of view, what optimizes different resources better? Activating/Deactivating UI elements or hiding and showing UI elements using CanvasGroup's alpha? 2 Answers

Changing UI for network chat 1 Answer

Two dynamic dropdowns from one source list 0 Answers

Load different render textures into Raw image object 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