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 Tinawchen · Nov 23, 2011 at 11:50 AM · guibuttontextfieldlabelappear

when button pressed, textfield appears

hey guys, i'm a newbie in Unity, and i'm working on an usability Platform.

I think i have an easy problem,.... but not easy enough for me...

i just want when someone press my button, a textfield appears!

How can i solve this problem? :(

Thanks a lot!! Tina :)

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

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by SkaredCreations · Nov 23, 2011 at 05:10 PM

Here is:

 public class TestScript : MonoBehaviour {

     private bool showForm = false;
     private string myText = "";

     void OnGUI()
     {
         if (!showForm)
         {
             if (GUI.Button(new Rect(0, 0, 100, 20), "Show Form"))
                 showForm = true;
         }
         else
         {
             myText = GUI.TextField(new Rect(0, 0, 100, 20), myText);
         }
     }
 }
Comment
Add comment · Show 12 · 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 Tinawchen · Nov 24, 2011 at 07:43 AM 0
Share

looks great, but how can i use this script? is it c#? and how can i use it on my camera? what is monobehavior??

Thank youuuu Tina :)

avatar image SkaredCreations · Nov 24, 2011 at 11:10 AM 0
Share

Yes it is C#, $$anonymous$$onoBehaviour is the base class of every attachable script component (http://bit.ly/rYPA9u), since this script is only displaying stuff on GUI you can attach it to whatever object, even the camera

avatar image Tinawchen · Nov 30, 2011 at 09:11 AM 0
Share

Assets/Buttons.cs(1,27): error CS0246: The type or namespace name `$$anonymous$$onoBehaviour' could not be found. Are you missing a using directive or an assembly reference?

Why is this? What do i have to do?

avatar image syclamoth · Nov 30, 2011 at 10:10 AM 1
Share

Yes, yes we are.

avatar image SkaredCreations · Nov 30, 2011 at 01:47 PM 1
Share

What does it mean "everytime"? You have to attach it only once in the hierarchy of a scene (of course before you hit "PLAY" button). If you mean that you need to use it in more than one scene, than you could create a prefab in Project and drag there the camera so you should use this prefab as your camera in every scene ins$$anonymous$$d of the default one.

Show more comments
avatar image
1

Answer by cj_coimbra · Nov 23, 2011 at 04:48 PM

private bool textFieldActive = false;

void OnGUI() { if (textFieldActive) { //place your textfield code here }

 if( GUI.Button(buttonRect, "Activate TextField") )
 {
     if (textFieldActive)
         textFieldActive = false;
     else
         textFieldActive = true;
 }

}

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
avatar image
0

Answer by Tinawchen · Nov 24, 2011 at 09:32 PM

hello ZioRed! What is monobehavior? and how can i use your script? is it c#? and how do i have to bind it to my camera?

Tina :)

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Problem with GUI.Button and other GUI items 1 Answer

Gui label and gui button 1 Answer

GUI Scripting button controls 1 Answer

How do I set a button to exit a GUI text field 0 Answers

GUI.Label positioning for many device resolutions 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