Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 Govain_C_R · May 21, 2021 at 01:14 PM · uibuttonbuttonseventsystemtroubleshooting

UI button not working

I'm doing a project and I created a UI canvas under which I added 3 empty GameObjects. In these empties, there are buttons. It worked properly before with no issue but then all the buttons in the 2 first empties stopped working. They react when you click them (by having a kind of gray tint) but they don't do call the function they're supposed to call.

I have - An event system

I've already tried : - Deleting and re-creating the event system - Add a Canvas group to the Main canvas GameObject - Add a Graphic Raycaster on the two empties with problematic buttons - Marking the buttons as interactable (they were already interactable anyway) - Restarting unity & playing the game (too many times)

The hierarchy of the UI :

 MainCanvas
      UIEmpty1
           Button1
      UIEmpty2
           Button2
           Empty
                Button3
                Button4
           Button4
           Button5
      UIEmpty3
           Button6
           Button7


Also : They're not all open at the same time

Comment
Add comment · Show 3
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 Hellium · May 21, 2021 at 01:55 PM 0
Share

If they are reacting to mouse hover and mouse press, the problem comes from your functions.

How have you added the callbacks? By code or from the editor?

avatar image Govain_C_R Hellium · May 21, 2021 at 01:57 PM 0
Share

I have no idea what a callback.

avatar image Hellium Govain_C_R · May 21, 2021 at 02:40 PM 0
Share

Callbacks = functions called by the button upon click

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Monsoonexe · May 21, 2021 at 05:56 PM

Since the Button reacts to being pushed visibly, this sounds like it could be a scripting error (an error in the code that the Button component calls onClick).

Add some kind of test event to the problem Button's onClick event in the Editor, something like en/disabling a Sphere that you can see or something. This will help you determine if it's a problem with the Button getting UI events (which sounds like is NOT the problem since it tints when pressed) or the code that is being called by the Button.

Are you rigging your event through the Editor or through a script? If you're rigging through a script, drop in some Debug.Log("someMessage");to make sure the AddListener code is working.

Comment
Add comment · 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 Govain_C_R · May 30, 2021 at 09:31 PM 0
Share

I tried that and it still didn't work. I defined keys on the keyboard and they work but the buttons don't. But, when I removed the lines for the buttons, it worked but instead of setting the boolean to true only when I press it, it sets it to true indefinitely.

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

223 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 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

Change properties of a button by pressing another button in Unity 1 Answer

Why do I have to double click on a button the first time? 4 Answers

Changing Color of Material with Bool and Unity UI 1 Answer

Runtime UI button creation: can't make an "OnClick" where I call a function from another script while sending a parameter. 2 Answers

button.onClick.AddListener(method); NOT Working 1 Answer


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