Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by EmmetOT · Jan 10, 2017 at 05:13 PM · editoreditorwindowscrollviewguilayout

Can't figure out how to make a small scrolling box inside an editor window

I'm trying to make my own 'console' of sorts in a custom Editor Window. I want it to work more or less the same as the regular console: messages are rendered inside rects which are stacked vertically inside a larger, scrollable rect, which is embedded in my editor window.

So far this is what I have:

alt text

which is created through the following code:

     private void ConsoleDrawer()
     {
         float margin = 20f;
         
         Rect rect = new Rect(margin, 100f + margin, Screen.width - (margin * 2), Screen.height - 200f);
 
         GUILayout.BeginArea(rect, GUI.skin.box);
             m_debugConsoleScroll = GUILayout.BeginScrollView(m_debugConsoleScroll, false, true);
                 GUILayout.BeginVertical();
 
                 for (int i = 0; i < 1000; i++)
                 {
                     GUILayout.BeginArea(new Rect(-2f, 30f * i - 1f, Screen.width, 30f), GUI.skin.box);
 
                     GUILayout.EndArea();
                 }
 
                 GUILayout.EndVertical();
 
             GUILayout.EndScrollView();
         GUILayout.EndArea();
     }

This seems quite similar to all the examples I can find elsewhere, but no matter how I order things or what parameters I change, the scroll area never seems to work how I want it to, i.e. grow to accommodate all 1000 smaller rects.

scrollview.png (2.9 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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Adam-Mechtley · Jan 13, 2017 at 10:49 AM

Why are you calling GUILayout.BeginArea inside of an area you have already created (i.e. the one inside of the ScrollView scope)? If you need a rect in there, you should instead use GUILayoutUtility.GetRect(), or just directly draw the controls you need (e.g., GUILayout.Label, GUILayout.Button).

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

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

Related Questions

Editor Camera Issue 0 Answers

Custom Editor Textarea cursor position 0 Answers

How to enter play mode on two separate Unity instances at the same time? 0 Answers

My EditorWindow won't display properly, even when commented out. 0 Answers

Is it possible to get Unity to compile specific scripts even if it can't compile the entire project because of errors. 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