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 Abacab · Jan 15, 2015 at 11:22 AM · c#buttonhideguibutton

Hiding "Next level" button if not finished

Hello!

I've tried hiding (or showing after finish) a next level button. I was able to do it when I created one in the script, but I'd like to do a physical button on the canvas.

How do I hide the button if finished = false?

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

1 Reply

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

Answer by Mmmpies · Jan 15, 2015 at 11:28 AM

Using the new 4.6 UI?

If so add a Canvas Group to it and you can alter the Alpha from 1 to 0 to hide the button, also Unclick BlockRaycast and Interactible so the button doesn't block mouse clicks in your game.

You can also gently reduce the alpha of a canvas group to fade out the button.

If the button is the only thing on the canvas then you should really base the canvasGroup on the actual canvas but you can also fade in and out individual elements by putting a canvas group on them.

EDIT:

Hold a reference to the button so:

 using UnityEngine.UI;
 
 ...
 
 public Button FinishButton;
 
 // then set the various stuff on the canvas group
 
 FinishButton.GetComponent<CanvasGroup>().alpha = 0; // or 1 to show
 FinishButton.GetComponent<CanvasGroup>().interactable(false);

Sorry for any typos as I don't have access to unity, if you just want a quick method you can just set the button's active to false ...

 FinishButton.SetActive(false);

Which is quicker but you can't do fancy fade in or out. As with the Alpha above being set to 1 to show it, set all the false values to true when you enable the button again.

Comment
Add comment · Show 3 · 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 Abacab · Jan 15, 2015 at 11:40 AM 0
Share

Thank you, but how do I then make it visible when finished = true?

Otherwise a great answer.

avatar image neciu · Jan 30, 2015 at 08:56 PM 0
Share

Thank you! This is what I was looking for!. Unfortunately I can't upvote this answer :(.

avatar image Mmmpies · Jan 30, 2015 at 09:02 PM 1
Share

Don't worry @neciu just glad it helped.

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

27 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

Related Questions

Multiple Cars not working 1 Answer

hide button 1 Answer

Distribute terrain in zones 3 Answers

How do I make a function not appear on UnityEvents / Button OnClick lists? 0 Answers

In game Escape menu displays all the time 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