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 /
This question was closed Apr 09, 2019 at 10:51 AM by mchts for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by mchts · Apr 07, 2019 at 07:47 PM · editoreditor-scriptingeditorguilayoutvertical

EditorGUILayout.BeginVertical indent level

Hi all,

I created an editor with some vertical groups in it and i want to give indent to them. Everything works fine except the style of the group. If i apply a style to that vertical group after giving an indent like:

 EditorGUI.indentLevel++;
 EditorGUILayout.BeginVertical("box");
 EditorGUILayout.LabelField("blah");
 EditorGUILayout.EndVertical();

the label moves right as expected but the box is drawn as wide as the inspector window no matter what. I tried adding gui layout option width but it didn't work. Any ideas?

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

  • Sort: 
avatar image
1
Best Answer

Answer by Bunny83 · Apr 08, 2019 at 12:13 AM

The static "indentLevel" is only used by certain controls, mainly for their LabelField. It has no influence on how styles are drawn. As you might know the layout controls in almost all cases just wrap the normal EditorGUI controls but use EditorLayoutUtility.GetRect to aquire a layouted rect. The control itself will add the indent to it's rect. This is not the case for layout groups.


Note that the indent level is meant for the inspector only. You can "manually" indent a certain layout group by nesting it in a horizontal group with a "GUILayout.Space" as first element to specify the indent

 GUILayout.BeginHorizontal();
   GUILayout.Space(indent amount);
   GUILayout.BeginVertical("box");
     // some content
   GUILayout.EndVertical();
 GUILayout.EndHorizontal();

This will indent the whole box of the vertical group. Though if you want to mix your controls in the inspector with other things that have normal indented labels they probably won't line up. So it depends on what you want to do. By default layout groups do not have any concept of indention.

Comment
Add comment · Show 3 · 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 mchts · Apr 09, 2019 at 10:48 AM 0
Share

Doing so made the trick thanks.

avatar image BiomotionLab · Nov 05, 2019 at 07:51 PM 0
Share

When I do this, all other layouts inside the box are now sticking out to the right and getting clipped by the exact amount that the box is indent. $$anonymous$$now any way to offset this?

avatar image Bunny83 BiomotionLab · Nov 06, 2019 at 02:03 AM 0
Share

No, that's not the case unless you somehow specify a fix or $$anonymous$$ width for some elements and that width is too large to fit into the available space. It's also not clear in which context you need this. Of course if the window (or fixed clipping area) is too small to fit everything in there's no way to display everything besides using scrollbars.

Follow this Question

Answers Answers and Comments

145 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

Related Questions

Setting custom amount of space between elements in a custom inspector with EditorGUILayout ? 1 Answer

Custom Editor - Is there any way to detect whether the user is in Prefab editing mode? 1 Answer

Editor GUI object field stops working 0 Answers

Track when the value is changed and get it 0 Answers

Unity editor extension - create drag and drop (similar to Buildbox) 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