Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 madgreg · Mar 10, 2015 at 09:47 PM · uitouchevents

Unity 5/4.6 Is it possible to make a UI Element not clickage/touchable?

I have a grid of UI buttons that answer to the event OnClick, it works great Until I display some visual feedback over the button, in my case a UI Text that show a "Combo x2" information. The UI Text over the button gets the OnClick (nothing to do on that) so the Buttons behind doesn't get any OnClick events. I would like to make all Text I display over the button not clickable so my buttons gets all the events. How can I do that? I searched the docs there I could'nt find how to do this.

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

3 Replies

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

Answer by Kiwasi · Mar 11, 2015 at 04:06 AM

Add a CanvasGroup component. Set the property blocks raycast to false.

Comment
Add comment · 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 madgreg · Mar 11, 2015 at 03:55 PM 0
Share

Thanks! That did the trick!

avatar image bluelock3 · Jun 11, 2015 at 07:48 PM 0
Share

thanks helped so much with a bug! :)

avatar image
0

Answer by bartm4n · Mar 11, 2015 at 03:03 AM

The new UI elements are handled following the parent/child hierarchy that you have defined.

With that in mind, you might be able to make your popup text a child of the button, which is how I would do it anyways. Even if you want the popup to follow the mouse cursor, you could still do it this way with a little bit of scripting.

EDIT: Though somewhat obvious, I forgot to mention that you should disable the popup text and only enable it when you want it to be visible. I imagine you are already doing something similar.

For an example, look at how a default button appears when you add it. The text is a child, and does not intercept the click events.

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 Racoon022 · Mar 11, 2015 at 09:30 AM

Here is a script I wrote to swap between menus on a button click using the new UI. It's a little dirty as I just put it together the other day, but the part you're looking for is in OpenMainMenu() sub. Once I have this setup I just drag and drop menus around in the UI. Usually I have each sub menu in a canvas group, and the script toggles their visibility using alpha and disable blocking of raycasts so they can't block clicks on menu items "below" them while invisible. Although you're using text, the concept still applies if it is on a parent canvas, anything that is a child of that canvas will be effected. Let me know if you have any questions.

 public class MenuController : MonoBehaviour {
 
     public CanvasGroup mainMenu = new CanvasGroup();
     public CanvasGroup thisMenu = new CanvasGroup();
 
     public void Start()
     {
         
         CloseThisMenu(); 
         
         OpenMainMenu();
     }
     
 
     public void CloseThisMenu()
     {
         thisMenu.blocksRaycasts = thisMenu.interactable = false;//disallows clicks
         thisMenu.alpha = 0;   //makes menu invisible
         
     }
 
     public void OpenThisMenu()
     {
         thisMenu.blocksRaycasts = thisMenu.interactable = true;//allows clicks
         thisMenu.alpha = 1;  //makes menu visible
 
     }
 
 
     public void OpenMainMenu()
     {
         mainMenu.blocksRaycasts = mainMenu.interactable = true; //allows clicks
         mainMenu.alpha = 1;  //makes menu visible
     }
 
 }
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

"Capturing" "events" in Unity.... 1 Answer

Trigger UI element callback from script 0 Answers

How can i access the Image renderer? 1 Answer

Please help !! Have a little question about new UI and touch controlls. 1 Answer

Detecting Iphone Touches on Specific Areas of a GameObject 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