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 /
avatar image
0
Question by Zionmoose · Aug 25, 2016 at 11:35 AM · guieditoreditor-scriptingguilayoutgui-button

How To Best Match Editor GUI Content Heights

I am making some custom editor design scripts. When laying out things horizontally, I would like all content types to have the same height as the tallest element in the horizontal group. Another way to do it would be to somehow vertically center all elements in the horizontal score.

Here is an image of my problem. As you can see, the button that has an image in it causes the button to expand, so the height of the box no longer looks right.

alt text

Here is the code making those controls:

 buttonStyle = new GUIStyle("button");
 buttonStyle.border = new RectOffset(8, 8, 8, 8);
 buttonStyle.margin = new RectOffset(5, 5, 0, 0);
 buttonStyle.padding = new RectOffset(5, 5, 6, 6);
 buttonStyle.richText = true;
 buttonStyle.alignment = TextAnchor.MiddleCenter;
 buttonStyle.normal.background = EditorButtonNormal;
 buttonStyle.hover.background = EditorButtonNormal;
 buttonStyle.active.background = EditorButtonActive;
 buttonStyle.normal.textColor = TextColor;
 buttonStyle.hover.textColor = TextColor;
 
 boxStyle = new GUIStyle("box");
 boxStyle.margin = new RectOffset(5, 5, 4, 4);
 boxStyle.padding = new RectOffset(5, 5, 3, 3);
 boxStyle.richText = true;
 boxStyle.alignment = TextAnchor.MiddleLeft;
 boxStyle.normal.textColor = TextColor;
 
 using (var h = new EditorGUILayout.HorizontalScope())
 {
     if (GUILayout.Button(RkIconCache.Get("d_MoveTool On"), buttonStyle, GUILayout.Width(30)))
     {
 
     }
     GUILayout.Box("This is my box", boxStyle);
 }
 using (var h = new EditorGUILayout.HorizontalScope())
 {
     if (GUILayout.Button("<b>P</b>", buttonStyle, GUILayout.Width(30)))
     {
 
     }
     GUILayout.Box("This is my box", boxStyle);
 }


boxsize.png (11.5 kB)
Comment
Add comment · Show 1
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 Zionmoose · Aug 25, 2016 at 02:10 AM 0
Share

So I think I'm getting somewhere, but its not quite to my liking yet.

I'm basically just trying to extend the way they handle the disposable scopes to include GUILayout.FlexibleSpace. I extended the VerticalScope class, and added the FlexibleSpace to the constructor and the CloseScope() method, which is called in the disposal. Thing is, the flexible space in the constructor works fine, but the one in the CloseScope() method does not appear to work. Will FlexibleSpace not work in disposal?

 public class VertFlexScope : EditorGUILayout.VerticalScope
 {
     public VertFlexScope()
     {
         GUILayout.FlexibleSpace();
     }
  
     protected override void CloseScope()
     {
         GUILayout.FlexibleSpace();
         EditorGUILayout.EndVertical();
     }
 }

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

EditorGUI like light explorer window 1 Answer

EditorGUI, EditorGUILayout, GUI, GUILayout... pshhh... WHEN TO USE WHAT?! 3 Answers

GUILayout not working with Event.Use (Unity 4.0) 0 Answers

Change Text Size and height EditorGuiLayout.Popup 1 Answer

How to fix ArgumentException? 3 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