• 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
2
Question by Hyperion · Oct 05, 2013 at 12:09 AM · guibuttonenableinvisibleoff

Turning off ONE GUI button

Hello Everyone,

I've searched all over the internet for hours and can't find the answer. I want my GUI.Button to disappear when I click it. I can't seem to do it. Using enabled=false turns all GUI off, but I want only the button to disappear. Currently, after I click the button, the rest of my GUI appear, but right over the button, which stays visible.

I appreciate your help. -Hyperion

Comment
Add comment · Show 1
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 clunk47 · Oct 05, 2013 at 12:21 AM 0
Share
  • for searching before asking ;)

1 Reply

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

Answer by tw1st3d · Oct 05, 2013 at 12:12 AM

Try using a bool.

 using System.Collections;
 using UnityEngine;
 
 public class DisappearingButton : MonoBehavior
 {
     protected bool showButton1 = true, showButton2 = true;
     
     public void OnGUI()
     {
         if(showButton1)
             if(GUI.Button(new Rect(10, 20, 100, 20), "Turn Off 1"))
                 showButton1 = false;
         if(showButton2)
             if(GUI.Button(new Rect(10, 45, 100, 20), "Turn Off 2"))
                 showButton2 = false;
     }
 }
Comment
Add comment · Show 6 · 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 clunk47 · Oct 05, 2013 at 12:13 AM 1
Share

This is what I would tell the OP in my answer, so I'll just say +1 to you :D

avatar image tw1st3d · Oct 05, 2013 at 12:15 AM 1
Share

Thanks, I'm glad to know that I'm going in the right direction with my program$$anonymous$$g. Been kind of doubting myself with it since I keep getting stuck on tiny things for days.

avatar image Hyperion · Oct 05, 2013 at 12:19 AM 1
Share

Thank you! All the other answers I looked at were super ambiguous and resulted in headaches.

avatar image clunk47 · Oct 05, 2013 at 12:19 AM 0
Share

It gets frustrating, I'm still learning myself. Always stick w/ it though man, well worth the time and effort :)

avatar image tw1st3d · Oct 05, 2013 at 12:20 AM 1
Share

@Hyperion Glad I could help!

Show more comments

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

17 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

Related Questions

Move GUI elements. 0 Answers

Using GUI and check what button was pressed 1 Answer

GUI Button Disappearing 1 Answer

GUI Button to create another GUI 1 Answer

Making an options screen that changes? 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