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 Kaytee86 · Mar 31, 2012 at 09:49 AM · guibuttontextfieldlabeltextarea

Problem with GUI.Button and other GUI items

Hello. As long as i test my code in the editor everything is great, but when i build the exe file and run it the Buttons dont disappear like in the editor. The functionality is still the same.

 var site:int = 0;
 function OnGUI(){
     if(site==0){
         if(GUI.Button(Rect(0,0,120,30),"Button 1")){
             site = 1;
         }
     }
     else if(site==1){
         if(GUI.Button(Rect(0,40,120,30),"Button 2")){
             site = 2;
         }
     }
 }

In the editor:

There is "Button 1". After clicking on it "Button 1" disappears and "Button 2" appears. After clicking on "Button 2" this button disapears and there is no button anymore.

In the .exe:

There is "Button 1". After clicking on it "Button 2" appears and you can also see "Button 1" (without any functionality). After clicking on "Button 2" you can still see both buttons.

There is the same problem with other items like GUI.TextField, GUI.TextArea and GUI.Label.

I hope someone can help me with my little problem.

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
0

Answer by dvidunis · Mar 31, 2012 at 01:18 PM

in the example for the button you have to change: site = 2; to: site = 0;

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 Kaytee86 · Apr 01, 2012 at 03:13 PM 0
Share

I use site=2 to show no buttons anymore, but they are still drawn both and that is my problem. I want them to disappear but they disappear only in the editor and not in the exe.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

when button pressed, textfield appears 3 Answers

In androids about input of TextArea and TextField 0 Answers

Make button disappear, but show label. 1 Answer

GUI.Textfield backspace control + Button Style problem 0 Answers

GUILayout.TextArea/TextField 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