• 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
Question by Cranke · Oct 29, 2014 at 01:29 AM · uiclickpanel

Unity 4.6: How to disable ugui object so that you can click things behind it?

Hi,

I am trying to figure out how to click "through" a disabled ugui object. At the moment, things behind the disabled object cannot be clicked.

Here is an example setup:

  • Create ugui panel #1. Put a button in panel #1 that prints "YOU CLICKED ME!" when clicked.

  • Create ugui panel #2. Put a button in panel #2 that calls panel#2.SetActive(false) when clicked.

  • Put panel #2 over top of panel #1 (so you can't see panel #1 at the start).

Now, when you click the button in panel #2, panel #2 disappears and you can see panel #1 and its button; however, you cannot click the button in panel #1. It is as if panel #2 is still obscuring the ability to click through to panel #1.

Does anyone have any insight on this? How can I hide panel #2 AND allow clicking through to panel #1?

Thanks!

Comment
AlwaysSunny

People who like this

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

Answer by HarshadK · Oct 29, 2014 at 01:37 PM

I did exactly as you said and it worked for me.

See the image below, it shows the step by step output.

alt text

And here's the test code:

 public class UIClickTest : MonoBehaviour {
 
     public void ButtonOneClicked()
     {
         Debug.Log("Button One Clicked");
     }
     
     public void ButtonTwoClicked()
     {
         Debug.Log("Button Two Clicked");
         GameObject.Find("Panel#2").SetActive(false);
     }
 
 }

The two functions are attached to each of the buttons. You can also see the structure of UI elements in the hierarchy window.

Wondering why it didn't work for you.


testresult.jpg (93.0 kB)
Comment

People who like this

0 Show 1 · 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 Cranke · Oct 30, 2014 at 05:06 PM 0
Share

Thanks for the answer HarshadK. You are totally correct. Everything works when the panels are setup like I originally described in my question. I got the same result as you when I did it in a new project.

However, after tweaking the situation a little, I managed to reproduce my original results. See my posting below for details ...

Cheers

avatar image

Answer by Cranke · Oct 30, 2014 at 05:03 PM

Setting the panels up as per my original post will actually work fine; however, I've reproduced the originally described problem by setting the panels up a little differently ...

  • Same: Create ugui panel #1. Put a button in panel #1 that prints "YOU CLICKED ME!" when clicked.

  • New: Create ugui panel #2. Inside panel #2, create a panel #3 with a button that calls panel#2.SetActive(false) when clicked.

  • Same: Put panel #2 over top of panel #1.

Now, here is where things get interesting. Add a Vertical Layout Group to panel #2, add an image as a "source image" for the Image component of panel #3, and make the Image component of panel #3 inactive (by unchecking the box beside it in the Unity IDE).

When I set things up like above, now I cannot click through to panel #1 when panel #2 is SetActive(false). Strange ...

If I re-enable the Image component of panel #3 or if I change the Image component of panel #3 to not have a source image, things work as I expect (i.e. I can click on panel #1's button after panel #2 is SetActive(false)).

?!

Comment

People who like this

0 Show 2 · 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 Cranke · Oct 30, 2014 at 10:12 PM 0
Share

So, my problem is fixed because I never intended to disable the Image component of panel #3, but the behavior is still strange ...

avatar image HarshadK · Oct 31, 2014 at 01:02 PM 0
Share

You can post a bug report for this strange behavior.

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.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Increase height of panel w/ gridlayout when new objects added 1 Answer

Unity 4.6 UI Button Click Animation? 4 Answers

UGUI OnClick Event! 1 Answer

How do i check if mouse moved a certain distance? 2 Answers

Unity 5 UI buttons don't respond well with clicks when used in windows standalone with different resolutions. 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