Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 sumeetkhobare · Jul 10, 2015 at 11:36 PM · buttongui-button

UI.Button not working.

I am facing this weird problem with Unity's UI System.

I have a couple of buttons in my canvas, which work just fine. Then I have a Panel whose gameobject I set to Active after I win the level. Its a game win screen. I have a button as the child of this Panel. This button doesn't work at all.

If during runtime, I switch to scene view and move the button outside the canvas boundaries on screen, and then switch to game view and click the button, it works. and if I move it back in canvas boundaries, it doesn't work.

Did anyone face the same issue or have a solution to it?

Comment
Add comment · Show 2
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 jprocha101 · Jul 11, 2015 at 03:20 AM 0
Share

You might have another panel rendered on top of the button. Upload a screenshot of your hierarchy and we can look that over for any red flags.

avatar image sas_88 · Jul 11, 2015 at 06:23 AM 0
Share

check Event System whether exists in current scene or not.

3 Replies

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

Answer by DimitriUK · Jul 10, 2015 at 11:49 PM

Hey Sumeetkhobare,

I think I had your issue earlier..

I just simply did this:

  1. Click on Canvas.

  2. GameObject >> Create Empty Child

  3. You then drag panel in to that Empty Child.

  4. Click your Empty Child Object and create another Empty Child Object on the Empty Child object called something like Column1, or it's up to you.

  5. Drag your Button in to Column1 and that should keep it all neat and organised.

Let me know if this solution worked.

Comment
Add comment · Show 8 · 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 sumeetkhobare · Jul 11, 2015 at 09:49 PM 0
Share

Thanks for the answer, I will try this. I was thinking about the same.

avatar image sumeetkhobare · Jul 12, 2015 at 10:50 PM 1
Share

It worked. Thumbs up.

avatar image jprocha101 · Jul 12, 2015 at 10:53 PM 0
Share

This is more of a workaround, still sounds like you had a transparent panel rendered over your button. That panel on top of your button would have blocked interaction with it. That's why moving it off the canvas (aka out from under the overlaying panel) would let you interact with it. With the solution mentioned you moved your button onto a new panel rendered on top of the one originally blocking the button interaction.

Best to figure out exactly what you did wrong in order to avoid repeating the mistake.

avatar image sumeetkhobare · Jul 13, 2015 at 02:47 AM 0
Share

Well, I thought about that as well. I checked in 3D view, but my button was above the panel.(I tried below as well, in order to try my luck with 'reverse raycasting'). And as my button was the child of my panel, I am assu$$anonymous$$g that button is rendered after the panel.

avatar image jprocha101 · Jul 13, 2015 at 11:26 AM 0
Share

I don't think the whole z distance thing works for the new UI. You need to pay attention to the sorting order, and things get rendered from top to bottom based on the their position in the hierarchy. So if panel A was on top of panel B in the hierarchy then panel B would get rendered over anything in panel A.

Show more comments
avatar image
3

Answer by kojiornk · Aug 28, 2015 at 06:45 AM

Make sure you only have the "Canvas" component attached to the main canvas object, if you have this component attached to a panel or another UI element, buttons inside other UI objects won't work.

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 ieselisra · Jan 12, 2016 at 08:25 PM 0
Share

That was my problem. Thanks!

avatar image
0

Answer by panderson9149 · Oct 14, 2021 at 04:11 AM

I had a similar issue. I solved it by adding a Graphic Raycaster component to the parent game object the button was under.

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

26 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

Related Questions

Turn off my GUI Box when I click a button. 3 Answers

button pressed twice / Conversation text skip 5 Answers

Unity GUI Style with if Statements 1 Answer

Cases if a GUI.Button is clicked two or more times?? 2 Answers

OnGUI button changes size for resolution, but text doesnt? 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