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 /
  • Help Room /
avatar image
2
Question by MajorSquirrel · Feb 08, 2016 at 07:36 PM · uiscaleanchorcontent

Keep position of UI while using Horizontal Layout Group and Content Size Fitter

Hi there,

I am trying to design a nice menu with some features including localization. However, I might need some help about UI elements.

I am doing a menu with some buttons that are detached from the left side of the screen (so that there can be a cool little space) :

alt text

I was thinking about localization when I realized that, according to the language chosen by the player, the button width (meaning here the clickable area) would not be in accordance with the text width. That is why I used Horizontal Layout Group and Content Size Fitter thanks to Unity tutorial at part "Fit to size of UI element with child Text" and it fitted my expectations really well.

But I have a little problem, I suppose it is about anchors or something like that : when I change the text of a button (for example purpose), my button is completely offset from his initial position (the red arrow on the first screen, this cool little space you know) :

alt text

Is there a way to "keep the left side of a button" at a specific place and keeping at the same time the Content Size Fitter to expand to the right side ? Here is a visual of my expectation.

Thanks in advance for help :)

first.png (53.6 kB)
second.png (59.8 kB)
Comment
Add comment · Show 2
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 hexagonius · Feb 08, 2016 at 09:15 PM 0
Share

what exactly are you horizontally layouting? I see this as follows:

  • gameobject with vertical layout group, content size fitter and child alignment left center

  • your buttons as children of it with text left aligned

  • the whole thing offset from the left screen border and anchored there

avatar image MajorSquirrel hexagonius · Feb 08, 2016 at 09:17 PM 0
Share

@hexagonius I solved my problem and gave an answer ! I "horizontally layouted" each button, but you make me think of creating a parent for all buttons and assigning an unique configuration ins$$anonymous$$d of assigning them to each button.

1 Reply

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

Answer by MajorSquirrel · Feb 08, 2016 at 09:14 PM

Solved !

According to the Content Size Fitter doc page, moving the pivot of my buttons put correctly the button position after changing the text.

I had to put the pivot on each button by (0, 0) to keep the left side of my buttons at their place. :)

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 Rodoleia · Jan 07, 2019 at 10:06 AM 0
Share

Saved me after few hour of suffering! Thanks!

avatar image thealexguy1 · Mar 01, 2019 at 04:03 AM 0
Share

Thank you so much, I kept thinking there must be a way to solve this, and there was.

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

53 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

Related Questions

My GUI isn't scaling well with screen size 1 Answer

UI doesn't work in Editor sometime and never on tablet 0 Answers

How Do I Change UI Image Anchor Position To Hover Over GameObject? 1 Answer

Sketchup to unity scale 0 Answers

Content Size Fitter doesnt work :( 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