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 WillNode · May 19, 2015 at 02:25 PM · editoronguitextarea

Editor TextArea with Scrollbar not working properly

Hi Guys, i'm trying to have a TextArea with scrollbar enabled, however, doesn't work properly, my script :

 void OnGUI () {
     // ...
     Rect area = EditorGUILayout.GetControlRect();
     area.height = position.height - area.yMin-50;
     Rect a = area;
     s = EditorGUILayout.BeginScrollView (s,false,true,GUILayout.Height ( area.height) );
     a.width -=  20;
     a.width /=2;
     a.height = EditorGUIUtility.singleLineHeight * ou.Length;
     EditorGUI.TextArea (a ,output);
     a.x += a.width;
     EditorGUI.TextArea (a ,ou);
     EditorGUILayout .EndScrollView();
 }

this is what happens, the ScrollView are not scrolling all area control property. it always appear short even when I'm set a very long text. did I miss something?

alt text

PS : bonus point if you know how to get Scrollbar width

untitled.png (19.6 kB)
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
4

Answer by Nighfox · Jan 23, 2018 at 12:10 PM

Add an ExpandHeight parameter to EditorGUILayout.TextArea:

 scroll = EditorGUILayout.BeginScrollView(scroll);
 text = EditorGUILayout.TextArea(text, GUILayout.ExpandHeight(true));
 EditorGUILayout.EndScrollView();


Not sure what happened to @WillNode by now, but still might be useful to some who are still finding for a solution.

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 superboyjohn · Jan 27, 2019 at 03:46 PM 0
Share

This is good..Also here is a updated version for those who are looking in future

 scroll = EditorGUILayout.BeginScrollView(scroll, GUILayout.Height(100));
         hintIds=EditorGUILayout.TextArea(hintIds, GUILayout.ExpandHeight(true));
         EditorGUILayout.EndScrollView();

Source: -https://answers.unity.com/questions/908365/how-do-i-add-a-scrolling-input-text-box-in-an-edit-1.html

avatar image
1

Answer by BahamutGundam · Aug 24, 2020 at 02:23 PM

 scroll = EditorGUILayout.BeginScrollView(scroll, GUILayout.Height(100));
          hintIds=EditorGUILayout.TextArea(hintIds, GUILayout.ExpandHeight(true));
          EditorGUILayout.EndScrollView();

In Unity 2019.4, using the above code won't auto-scroll the scrollbar when we press enter at the end of the TextArea. Similarly, pressing up-arrow and down-arrow won't scroll, which is bad IMO.

So far, the only way that I could find to be able to reproduce the same behavior as TextAreaAttribute is by using reflection.

         MethodInfo method = typeof(EditorGUI).GetMethod("ScrollableTextAreaInternal", BindingFlags.Static | BindingFlags.NonPublic);
         Rect rect = EditorGUILayout.GetControlRect(GUILayout.Height(300));
         object[] parameters = new object[] {
             rect, 
             textAreaContent, 
             scrollPos, 
             EditorStyles.textArea            
         }; 
         object methodResult = method.Invoke(null,parameters);
         scrollPos = (Vector2) (parameters[2]);
         string textAreaContent = methodResult.ToString();
 
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

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

Related Questions

Get height of TextArea when wordwrap is enabled? 1 Answer

(Solution) - Can't use GUILayout stuff in PropertyDrawer.OnGUI? 2 Answers

Huge Performance difference between docked and undocked EditorWindow 0 Answers

ShowObjectPicker ObjectSelectorClosed command is never issued 1 Answer

How to force Unity to Repaint an EditorWindow? 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