Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
4 captures
13 Jun 22 - 14 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 DallasP9124 · Jun 03 at 12:08 AM · editorcustom editorlayouteditorguieditorguilayout

Adding space() to BeginHorizontal() causes extra vertical spacing after certain amount.

I am working on a custom editor for a heirarchy of military unit structure. For each subunit of a given unit I display a new line in the list and indent it by the depth of the unit in the structure. You can see that in the image for more clarity.

I am noticing a behavior with EditorGUILayout.BeginHorizontal() where after applying a certain amount of space on a line there is extra vertical space occuring like something is trying to wrap because of the 'indent'. However, the furthest right thing in the horizontal layout is a GUILayout.FlexibleSpace(). I can't for the life of me find out what is causing the extra padding. When I reduce the indent amount added per line it works as expected with nothing extra vertically. I can determine based on the level and indent added per level that the Space() value is 40.

Here is a simplified script with the EditorGUILayout/GUILayout calls being made. Also note that the call is recursive to handle the subordinate units.

  private void UnitLine(string parent, string unit, int level)
         {
             var unitComp = _unitMap[unit];
             EGL.BeginHorizontal(GL.ExpandWidth(true));
             EGL.Space(level * 10);
             EGL.BeginHorizontal(GUI.skin.box, GL.ExpandHeight(false), GL.ExpandWidth(true));
             var doFoldout = _foldoutOpen.GetValueOrDefault(unit, false);
             
             _foldoutOpen[unit] = EGL.Foldout(doFoldout, "");
             
             if (GL.Button("E"))
             {
                 _activeEditUnit = unit;
             }
 
             if (GL.Button("S"))
             {
                 var newUnit = new UnitComposition
                 {
                     Id = Guid.NewGuid().ToString()
                 };
                 _unitMap[newUnit.Id] = newUnit;
                 _foldoutOpen[newUnit.Id] = false;
                 if (unitComp.Subordinates == null)
                 {
                     unitComp.Subordinates = new List<string>();
                 }
                 unitComp.Subordinates.Add(newUnit.Id);
                 _fs.Units.Add(newUnit);
             }
 
             if (GL.Button("D"))
             {
                 _markedForDelete = unit;
                 _markedForDeleteParent = parent;
             }
             
             GL.Space(10);
             
             EGL.LabelField($"Name: {unitComp.Name}", GL.ExpandWidth(false));
             GL.FlexibleSpace();
             EGL.EndHorizontal();
             EGL.EndHorizontal();
             EGL.Space(3);
             
             if (unitComp.Subordinates is not {Count: > 0} || !_foldoutOpen.ContainsKey(unit) || !_foldoutOpen[unit]) return;
             level++;
             foreach (var subordinate in unitComp.Subordinates)
             {
                 UnitLine(unit, subordinate, level);
             }
         }
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 DallasP9124 · Jun 03 at 01:01 AM

Here is an image of what I am seeing.alt text


bad-space.png (16.4 kB)
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

235 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 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 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

Custom Editor] FindProperty can't find a specific property!,CustomEditor] FindProperty can't find specific object 0 Answers

How to create an Editor for Imported Objects imported from a ScriptedImporter? 1 Answer

EditorGUILayout.EnumPopup shows always the same selected option but works as programmed 1 Answer

Dynamically sized list of toggles in custom inspector? 0 Answers

Editor Int sliders affecting each other 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