• 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 MaceB · Dec 02, 2018 at 05:06 AM · inspectorcustom editorcustom inspectorobjectfieldfoldout

Custom Inspector: How to Align EditorGUILayout.Objectfield in a Horizontal Group with other EditorGUILayout.Objectfield that aren't in Horizontal Groups?

I've made a Foldout and a Objectfield in a horizontal group but the Objectfield isn't aligning with the other Objectfields in my inspector that aren't in horizontal groups.

I would like for the 2 Objectfields which are inside their horizontal groups to align with the other Objectfields and also adjust their width with them when the inspector width is changed.

 EditorGUILayout.BeginHorizontal();
         showCurrentLevelFoldout = EditorGUILayout.Foldout(showCurrentLevelFoldout, "Current Level");
         progressScript.currentLevelBackgroundImage = (Image)EditorGUILayout.ObjectField(progressScript.currentLevelBackgroundImage, typeof(Image), true);
         EditorGUILayout.EndHorizontal();
 
         if (showCurrentLevelFoldout) {
             EditorGUI.indentLevel++;
             progressScript.currentLevelFill = (Image)EditorGUILayout.ObjectField("Current Level Fill", progressScript.currentLevelFill, typeof(Image), true);
             progressScript.currentLevelText = (Text)EditorGUILayout.ObjectField("Current Level Text", progressScript.currentLevelText, typeof(Text), true);
             EditorGUI.indentLevel--;
         }
 
         EditorGUILayout.BeginHorizontal();
         showNextLevelFoldout = EditorGUILayout.Foldout(showNextLevelFoldout, "Next Level");
         progressScript.nextLevelBackgroundImage = (Image)EditorGUILayout.ObjectField(progressScript.nextLevelBackgroundImage, typeof(Image), true);
         EditorGUILayout.EndHorizontal();
 
         if (showNextLevelFoldout)
         {
             EditorGUI.indentLevel++;
             progressScript.nextLevelFill = (Image)EditorGUILayout.ObjectField("Next Level Fill", progressScript.nextLevelFill, typeof(Image), true);
             progressScript.nextLevelText = (Text)EditorGUILayout.ObjectField("Next Level Text", progressScript.nextLevelText, typeof(Text), true);
             EditorGUI.indentLevel--;
         }

Here's what's happening: alt text

Here's what I want to be happening: alt text

screen-shot-2018-12-01-at-114046-pm.jpg (99.6 kB)
screen-shot-2018-12-01-at-115311-pm.png (44.1 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 MaceB · Dec 02, 2018 at 05:09 AM 0
Share

If someone could $$anonymous$$ch me how to do a line break in these questions, that'd be cool too. I did the double space + enter but as you can see, it didn't work out

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

98 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

Related Questions

Is there any way to hide the "Object picker" of an EditorGUILayout.ObjectField ? 2 Answers

Custom tree-like editor 0 Answers

How to Hide/Show List or Array in the inspector based on a variable? 0 Answers

Custom Inspector "Multi-object editing not supported" 4 Answers

Should I use Inspector or custom editor window? 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