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
1
Question by Ncyphe · Feb 23, 2015 at 07:31 PM · editorwindowonguiscrollingeditorguilayout

How do I add a scrolling input text box in an EditorWindow? (more info added)

How do I add a scrolling input text box in an EditorWindow?

I've been searching for a while, trying to figure out how to make a scrolling text input box for my Unity Addon I'm building. I've had 0 success in finding a solution that works.

In essence, I need to add a scrolling editable text area to my editorwindow to allow the user to input data of unknown length.

I've tried the following, and no luck.

 Vector2 ScrollPos;
 String ParseData = "";
 ScrollPos = EditorGUILayout.BeginScrollView(ScrollPos,GUILayout.Height(100));
     EditorGUILayout.TextArea(ParseData,GUILayout.Height(200));
 EditorGUILayout.EndScrollView();

This is the structure of the code I've been seeing everywhere; however, it only encases the textarea with a scroll bar, and doesn't add it to the textarea itself. If the TextArea is larger than the scroll height, it can scroll the TextArea; however, it has no effect on the text inside the TextArea. As I add lines of text into the TextArea, when the text passes the end of the TextArea, there is no way to scroll the text up or down to see the rest.

Example Images: This first images shows text loaded into the TextArea and the scroll bar already aligned at the bottom. alt text

When I add a few lines into the TextArea, the text simply gets pushed off the edge of the TextArea, and the scrollbar does nothing to compensate for this. I've determined that the ScrollView is only encompassing the TextArea, and not working with the TextArea. alt text

I need the scrollbar to be able to scroll the TextArea to allow the user to scroll up and down through the text he writes into the TextArea.

Am I doing it wrong, is there supposed to be a different way to do this?

Note to Mods: My original question was rejected due to lack of information; however, after adding more information, I couldn't figure out how to resubmit the question, so I caved and created a new question.

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 spiceboy9994 · Feb 23, 2015 at 11:42 PM 0
Share

What version of Unity are you using?. Is it viable to switch to 4.6 beta?. If this is the case, the ScrollRect is much more friendly. Check this out: http://unity3d.com/learn/tutorials/modules/beginner/ui/ui-scroll-rect

avatar image Ncyphe · Feb 24, 2015 at 12:48 AM 0
Share

Based on responses from a different post on a different site, I don't think the new 4.6 GUI elements will work within Unity Editor components. At least, I haven't found anyone to present a way to use the elements inside an EditorWindow.

avatar image gfoot · Feb 24, 2015 at 02:52 AM 1
Share

I have tried to do this before and failed - I came to the conclusion that it is just not supported. I got odd behaviours like the scroll view text selection appearing outside the bounds of my Inspector control. Not reassuring! I gave up and made my text edit box just automatically spawn with about enough lines to hold the text without scrolling, based on the current content. It was a little funky when the text was edited, but passable.

avatar image skylem · Feb 24, 2015 at 03:13 AM 1
Share

you could break up the gui, if it exceeds a certain length creating a new gui for anything written past the length that fits on the screen then u could toggle between these with ur mouse scroll, u can use String.Length to deter$$anonymous$$e the amount of characters in the text field and if the character exceeds a pre deter$$anonymous$$ed maxAmount spread the information over 2 gui ins$$anonymous$$d of 1. if u need more information let me know. Edit -- forgot to include, the way in which u would break up your text

 if(string.Length > 30) {
 string.Split (","[0]);
 }

this is literally just the code u might need i haven't tested it but it should be applicable to what ur trying to achieve.

1 Reply

· Add your reply
  • Sort: 
avatar image
4

Answer by Habib Loew · May 08, 2015 at 10:26 PM

I believe the issue you're running into is that you're setting a fixed height on your TextArea. In order to achieve the behavior that you're after you should either let the TextArea manage its own size (which can look a little funky if it gets shorter than the ScrollView) or simply have it expand to fill the scroll area, like this:

 ScrollPos = EditorGUILayout.BeginScrollView(ScrollPos,GUILayout.Height(100));
   EditorGUILayout.TextArea(ParseData, GUILayout.ExpandHeight(true));
 EditorGUILayout.EndScrollView();
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:43 PM 0
Share

Thanks for this..

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Window Editor - Particle Effect Window Layout 0 Answers

OnGui elements as objects? 2 Answers

Keep equal width for panels in EditorGUILayout.HorizontalScope 0 Answers

Unity Mobile ScrollView? 0 Answers

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