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
46
Question by ALterEgo809 · Jan 31, 2015 at 02:49 AM · button

I created an UI button but click does not work.

Hi everybody, I'm trying to make a simple RestartGame Button for my game, the problem is that once I add the button I can't click on It, it's like it's disabled, I wrote my script for the button and everything but the button does not work, no click, no mouseover effect, nothing. Any Ideas?

Comment
Add comment · Show 6
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 Derek-Wong · Jan 31, 2015 at 05:42 AM 0
Share

It is good if you can post a screenshot of how your button's object inspectorvlooks like and the structure od your gameobject

avatar image ALterEgo809 · Jan 31, 2015 at 07:26 PM 1
Share

Do I need to have one EventSystem object for each button I use? y added another button and I'm Having the same problem for the second one. The first one is fine but the second one is like it's disabled or something.

avatar image Derek-Wong · Feb 01, 2015 at 04:08 AM 0
Share

no, each scene only need 1 event system. how do you create youe button? if you right click > creare> ui> button it ahould automatically gen everything u need for you

avatar image garg.akshit · Apr 05, 2016 at 07:26 AM 0
Share

hello all!! $$anonymous$$y buttons still not work. I have canvas, event system. but nothing happens when i hover my mouse over the buttons.. plz help.. also i have tried all answers including @Bored$$anonymous$$ormon

avatar image Casiell garg.akshit · Jul 19, 2016 at 09:50 AM 0
Share

I didn't see anyone mentioning that so maybe this will help:

  1. On your button object you have Button(Script) component

  2. In the component there is On Click() "window"

  3. Press + in the bottom-right corner

  4. Drag your script to place for object

  5. From dropdown list select your script and choose which function should activate when you click your button

I hope I understood question correctly and that you will understand my answer as I'm not the best english speaker :)

avatar image lakhbir · Jan 29, 2020 at 06:59 AM 0
Share

Some time it happens if your offline license invalid. alt text

image-2020-01-29t05-56-14-636z.png (50.0 kB)

33 Replies

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

Answer by Kiwasi · Jan 31, 2015 at 02:52 AM

For a button to work you need the following in your scene

  • A button that is a child of a canvas object

  • The canvas object must have a GraphicRaycaster component

  • There must be an EventSystem object somewhere in your hierarchy.

Unity will build all this automatically if you create your button from the GameObject menu. But not if you add a button component manually.

Comment
Add comment · Show 11 · 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 ALterEgo809 · Jan 31, 2015 at 01:48 PM 9
Share

The EventSystem object wasn't in my hierarchy, I Added it and my button works fine, thanks a lot.

avatar image grimmy · Apr 20, 2015 at 08:41 PM 4
Share

It's also worth noting that if you somehow have 2 event systems in your scene the buttons will also stop working. You get a yellow warning message but it's easily missed.

avatar image el_santo · Aug 03, 2015 at 12:41 PM 2
Share

I get this issue at new Unity 5 project. Restart ide and issue is dissapear.

avatar image ckbrewer15 el_santo · Sep 29, 2015 at 03:33 AM 0
Share

This worked for me using Unity 5.2, thanks.

avatar image gianticristian · May 06, 2016 at 02:23 PM 0
Share

When you create a UI element, it will add an EventSystem and the GraphicRaycaster. In my case I did not use the "usual way". Thanks to you my friend :)

avatar image marcellus00 · May 30, 2016 at 02:48 PM 0
Share

Also, theres shouldnt be any additional colliders on a button.

Show more comments
avatar image
22

Answer by remption · Feb 02, 2016 at 05:32 PM

In addition to BoredMormon's answer: If you have multiple Canvases, you may need to specify the Sort Order for each (or some) in their Canvas components

For example, I had a HUD Canvas that's always present, and a Paused Canvas that is active when the game is paused. I had to set the Paused Canvas SortOrder to be higher, so that it's "in front" of the HUD. Otherwise, the raycast would hit the HUD Canvas first, and wouldn't register with the Paused Canvas's buttons.

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 jacksonho4 · Jan 10, 2018 at 01:16 AM 0
Share

this was my problem. I have resolved that now, but do you think it is a good idea to have multiple canvases set up in a single game?

I have many as I have been using different and more complex animations on each canvas individually.

I tried to use panels initially to animate an overlapping animation making certain buttons available and others greyed out in the background, but the overlapping of the panels was not working out properly, so I set these objects on individual canvases and used a canvas group sorting layer option ins$$anonymous$$d.

any thoughts?

avatar image tomcarnevale · Jun 24, 2020 at 01:25 PM 0
Share

Additionally, a frequent error I make that brings me back here is sometimes I have a canvas childed to the main canvas. I don't know why or how I would do this on accident. But, that child canvas is unnecessary AND if the child doesnt have a graphic raycaster, it will not function. So check your hierarchies!

avatar image
14

Answer by webspawn · Jan 28, 2016 at 01:29 PM

Hi, I don't know why but my EventSystem was with the option Force Module Active unchecked, when I checked this option my button works.

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 mohammad-alavi-74 · Apr 19, 2016 at 10:20 PM 0
Share

thank youuuuuuu!!!!!

avatar image dylanpierce mohammad-alavi-74 · Jun 28, 2016 at 04:20 PM 1
Share

With adding the Graphic Raycaster this solved my problem. Thank you!

avatar image
5

Answer by Mohobie · Sep 19, 2015 at 08:52 PM

I recently encountered a loss of my working modal. I found that it was due to the mouse being locked by another script that made my click not actually fire on the button. Just a thought for anyone who might be looking.

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 rukaiyasneha118 · Dec 29, 2020 at 01:58 PM 0
Share

If the mouse pos is locked, how do we unlock the mouse position?

avatar image jwaddilovejones rukaiyasneha118 · Apr 17, 2021 at 10:16 AM 0
Share

This was the problem for me, adding Cursor.lockState = CursorLockMode.None; to the pause state of my script unlocked the mouse and fixed the issue.

avatar image
3

Answer by SnStarr · Jan 31, 2015 at 05:52 AM

@BoredMormon is correct, but if it is still not working, might I add that you also need to add a using statement to your script: using UnityEngine.EventSystem;

Comment
Add comment · Show 4 · 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 Connor_Epic · Aug 12, 2015 at 07:56 PM 2
Share

UnityEngine.EventSystems;

avatar image tgsoon2002 · Sep 11, 2015 at 03:37 AM 0
Share

In my game, I have a menu with several butt(6th ,7th, 8th) they just not work. I dont know what happen. I even I duplicate from the working button, they still not work.

avatar image tgsoon2002 tgsoon2002 · Sep 11, 2015 at 03:45 AM 1
Share

I found the problem. I have another gameobject with text component invisible, but not deactivate at the same location, not in the save parent . So when i hover over it. it select the other game object but not the button i have. Now i deactivate it. it work just fine

avatar image dval tgsoon2002 · Dec 01, 2015 at 11:46 PM 0
Share

This was similar to my issue. Your observations helped me find the issue, Thanks. I had a dynamically sized text area that covered part of the button. I changed the order in the Hierarchy panel, and now all is well.

  • 1
  • 2
  • 3
  • 4
  • 5
  • ›
  • »

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

78 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

Related Questions

Cannot click UI button. 4 Answers

Can't to get Button script from gameobject in unity 0 Answers

How to play a sound for a Game Jam Menu Template button 0 Answers

SDK to create playback? 0 Answers

set angle on y Camera no sphere 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