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 DocteurCox · Jun 18, 2013 at 08:40 AM · c#guitextfieldtextarea

GUILayout.TextArea/TextField not working.

Hello there.

I'm having a strange problem with GUILayout's TextArea and TextField functions. While I used it several time before without having any problem, I can't seem to find out what's wrong here.

 _currentFile = GUILayout.TextArea(_currentFile);

Where _currentFile is a member of my MonoBehaviour. This variable is only edited here. Does someone know what the hell is going on with TextField/TextArea all of a sudden ?

Thanks in advance. :)

Comment
Add comment · Show 4
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 PAEvenson · Jun 18, 2013 at 11:50 AM 1
Share

not really enough information to help you out here... What exactly is it doing?

avatar image Bunny83 · Jun 18, 2013 at 12:08 PM 0
Share

Exactly. What code is around this line? GUILayout uses layouting groups, so it depends on the other elements how big and where the area / field will show up.

  "I can't seem to find out what's wrong here."

sorry, but we can't either...

avatar image DocteurCox · Jun 18, 2013 at 12:39 PM 0
Share

Here's the whole OnGUI code (it's a file browser) :

GUILayout.BeginArea(new Rect ( 30, 30, Screen.width-60, Screen.height-60), "Enregistrer sous...", (GUIStyle)"box");

         GUILayout.Space(30);
         
         GUI.skin.box.alignment = TextAnchor.$$anonymous$$iddleLeft;
         
         // top toolbar
         GUILayout.BeginHorizontal();
             // Display current directory
             GUILayout.Box(_currentDir);
         
             // Goto parent button
             DirectoryInfo parent = new DirectoryInfo(_currentDir).Parent;
             if ( parent == null || !parent.FullName.Contains( _viewScope ) )
                     GUI.enabled = false;
             if ( GUILayout.Button(_parentTex,GUILayout.Width(GUI.skin.button.fixedHeight) ) ) 
                 RegisterNewLocation(new DirectoryInfo(_currentDir).Parent.FullName);
             GUI.enabled = true;
     
             // Previous button
             if ( _historyIndex <= 0 ) GUI.enabled = false;
             if ( GUILayout.Button(_previousTex,GUILayout.Width(GUI.skin.button.fixedHeight) ) ) 
                 _currentDir = _history[--_historyIndex];
             GUI.enabled = true;
             
             // Next button
             if ( _historyIndex >= _history.Count-1 ) GUI.enabled = false;
             if ( GUILayout.Button(_nextTex,GUILayout.Width(GUI.skin.button.fixedHeight) ) ) 
                 _currentDir = _history[++_historyIndex];
             GUI.enabled = true;
         GUILayout.EndHorizontal();
     
         //Debug.Log("History Index : " + _historyIndex + "/ History nb elements : " + _history.Count);
         
         GUI.skin.box.alignment = TextAnchor.UpperCenter;
     
         GUILayout.Space(10);
         
         // $$anonymous$$ain panels
         GUILayout.BeginHorizontal();
         
             // DIR VIEW
             _scrollPosDirView = GUILayout.BeginScrollView(_scrollPosDirView, "box", GUILayout.Width(Screen.width*0.25f));
             
             GUILayout.BeginHorizontal();
             GUILayout.Label(_dirTex, GUILayout.Height(GUI.skin.button.fixedHeight), GUILayout.Width(GUI.skin.button.fixedHeight));
             
             if ( _viewScope.Equals(_currentDir) ) GUI.SetNextControlName("SelectedDir");
             
             if ( GUILayout.Button ( new DirectoryInfo(_viewScope).Name ))
             {
                 _currentDir = _viewScope;
             }
             
             GUILayout.EndHorizontal();
             
             GUI.FocusControl("SelectedDir");
             DisplayRecursively(_viewScope, _currentDir);
             GUILayout.EndScrollView();
         
             // FILE VIEW
             _scrollPosFileView = GUILayout.BeginScrollView(_scrollPosFileView, "box");
             DisplayIconView(_currentDir);
             GUILayout.EndScrollView();
         
         GUILayout.EndHorizontal();
         
         GUILayout.Space(5);
         
         // Filename text field
         GUILayout.BeginHorizontal();
             GUILayout.Label("Nom du fichier : ", GUILayout.Width(Screen.width*0.2f) );
             _currentFile = GUILayout.TextArea(_currentFile);
         GUILayout.EndHorizontal();    
     
         // Error Box
         GUILayout.Box(_error);
     
         // Confirm buttons
         GUILayout.BeginHorizontal();
             GUILayout.Space(Screen.width*0.6f);
             if(GUILayout.Button("O$$anonymous$$"))
             {
                 
             }
             if(GUILayout.Button("Cancel"))
             {
                 _callback("");
                 Destroy(this.gameObject);
             }
         GUILayout.EndHorizontal();
     
     
     GUILayout.EndArea();
avatar image DocteurCox · Jun 18, 2013 at 02:06 PM 0
Share

I think I found what part of my code is wrong :

 // $$anonymous$$ain panels
        GUILayout.BeginHorizontal();
 
          // DIR VIEW
          _scrollPosDirView = GUILayout.BeginScrollView(_scrollPosDirView, "box", GUILayout.Width(Screen.width*0.25f));
 
          GUILayout.BeginHorizontal();
          GUILayout.Label(_dirTex, GUILayout.Height(GUI.skin.button.fixedHeight), GUILayout.Width(GUI.skin.button.fixedHeight));
 
          if ( _viewScope.Equals(_currentDir) ) GUI.SetNextControlName("SelectedDir");
 
          if ( GUILayout.Button ( new DirectoryInfo(_viewScope).Name ))
          {
           _currentDir = _viewScope;
          }
 
          GUILayout.EndHorizontal();
 
          GUI.FocusControl("SelectedDir");
          DisplayRecursively(_viewScope, _currentDir);
          GUILayout.EndScrollView();
 
          // FILE VIEW
          _scrollPosFileView = GUILayout.BeginScrollView(_scrollPosFileView, "box");
          DisplayIconView(_currentDir);
          GUILayout.EndScrollView();
 
        GUILayout.EndHorizontal();

I still don't know how to solve that issue, but if I delete that part, my TextField works just fine. There must definitely be something with the GUI system that I don't understand.

1 Reply

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

Answer by DocteurCox · Jun 18, 2013 at 02:39 PM

I finally found what was wrong. To highlight some elements, I used GUI.FocusControl which prevented me from focusing the TextField by clicking on it.

Really sorry for that useless question :x

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

16 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

Related Questions

In androids about input of TextArea and TextField 0 Answers

Problem with GUI.Button and other GUI items 1 Answer

Prevent IOS keyboard from showing 0 Answers

GUI Text field? How do I make the text so it goes on more then one line? 1 Answer

Attach Text data to gameobjects by player 0 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