Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by Alpheon · Jul 24, 2012 at 01:46 AM · editorcustomalignment

How to align a toggle box to the right of a custom editor window?

Hi, I'm writing a custom editor window at the moment, and I'm using BeginHorizontal() and EndHorizontal() to put an EditorGUILayout.Foldout() next to an EditorGUILayout.Toggle box. Unfortuantely, when I have these two options following, the toggle box is aligned to the middle of the editor window, even when resizing the window. Is there a way to get the toggle box aligned to the right of the editor window?

I've tried using a custom GUIStyle, which changes the text alignment, as well as the amount of right padding, hoping that might work, but no avail, it simply makes the toggle box disappear completely.

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

3 Replies

· Add your reply
  • Sort: 
avatar image
9
Best Answer

Answer by ScroodgeM · Jul 24, 2012 at 07:17 AM

make

GUILayout.FlexibleSpace();
before toggle inside horizontal block
Comment
Add comment · Show 2 · 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 Alpheon · Jul 25, 2012 at 01:01 AM 0
Share

Unfortunately this doesn't seem to work for me. Here's the UI code for what I'm doing at the moment:

EditorGUILayout.BeginHorizontal();

foldoutActive = EditorGUILayout.Foldout(foldoutActive, foldoutID + " " + foldoutName);

GUILayout.FlexibleSpace(); toggleActive = EditorGUILayout.Toggle(toggleActive);

EditorGUILayout.EndHorizontal();

I believe I need to use GUILayout.BeginArea for flexible space to work, like in the example for the function in Unity Scripting Reference?

avatar image Alpheon · Jul 25, 2012 at 01:41 AM 0
Share

Turns out the toggle had a massive amount of white space to the right of it, which caused it to end up way out of place. Just used GUILayout.width(15), which got rid of all the white space. Thanks for the help though Scroodge!

avatar image
-1

Answer by CaJerry87 · Dec 20, 2016 at 07:45 AM

No No No, read my answer on http://answers.unity3d.com/answers/1288008/view.html on "HOW TO ADJUST THE SIZE OF YOUR BEGINHORIZONTAL/VERTICAL"...it should answer it all.

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

Answer by SplunkyDev · Sep 28, 2020 at 10:47 AM

ScroodgeM's solution worked for me, the aligned image is with GUILayout.FlexibleSpace(); and unaligned image is without it


with-guilayoutflexiblespace.jpg (42.5 kB)
without-guilayoutflexiblespace.jpg (48.7 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

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How can I right-justify (align) a custom editor label? 1 Answer

Unity editor and inspector header 0 Answers

Subfolder Windows, how to? 1 Answer

Repainting an EditorWindow when it's not the current focus? 3 Answers

Extending "GameObject/Create Other" with own prefab 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