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
0
Question by delta25 · Dec 16, 2011 at 12:28 PM · guibuttonstextbox

text box and button won't display

hey guys, can you help me out please... i have the following code, which should to the best of my knowledge, display a button, and once it is clicked, a method call thing() [its a temporary name haha] should be called. My problem is this the print("HELLO") is run, but the text box and secondary button never appear for some reason. Any help would be greatly apretiated. the following is the code. var word: String;

function OnGUI(){

 if (GUI.Button(Rect(20,20,100,20), "Import Image")){

     thing();

 }        

}

function thing(){

 print("HELLO");

 word=GUI.TextField (Rect (20, 50, 200, 50), word);    

 if (GUI.Button(Rect(20, 80, 100,20), "SUBMIT")){

     print(word);

 }

 return;

}

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

2 Replies

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

Answer by cj_coimbra · Dec 16, 2011 at 01:15 PM

That´s because they appear for a very short period once you click your other button that call thing() function. Put your textfield call outside that function and inside OnGUI() and it will display.

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 delta25 · Dec 16, 2011 at 01:26 PM 0
Share

i know but i only want to see the text field after the button is clicked...if i do it inside the OnGUI() it will be always there

avatar image cj_coimbra · Dec 16, 2011 at 01:35 PM 1
Share

I see. Well, wrap it around a boolean like:

if (buttonWasClicked == true) { //your textfield code here }

And then you start this buttonWasClicked variable with false, when you click your first button, set it to true. That way, your textfield will be displayed only after clicking even if it´s outside the thing() function. Inside thing() it´s not gona happen.

avatar image delta25 · Dec 16, 2011 at 01:47 PM 1
Share

thank you good sir...you solved it for me. thanks

avatar image
0

Answer by delta25 · Dec 16, 2011 at 09:01 PM

i know but i only want to see the text field after the button has been clicked..

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Making Text Boxes With Letters Appearing One At A Time 2 Answers

GUI buttons glow/flash/fade between textures 0 Answers

How do I make a custom font for a GUI button? C# 1 Answer

Tutorials for 2D game GUI 2 Answers

In Game Notepad 2 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