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 /
avatar image
0
Question by siddharth3322 · Apr 08, 2016 at 07:14 AM · uiunity5horizontal

Display width stretched buttons in UI

I want to display button in its full width. Basically I have achieved following by spending time on this.

alt text

At present you are clearly seeing gap between buttons. I want to remove these gaps for all aspect ratios. I want each of my button of full width. At present I have added Horizontal Layout Group to parent of these 3 buttons. Each 3 buttons contain following Layout Element script.

alt text

Now I am waiting for some clever reply. Please give me some hint in this.

screen-shot-2016-04-08-at-124248-pm.png (16.2 kB)
screen-shot-2016-04-08-at-122637-pm.png (27.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 siddharth3322 · Apr 08, 2016 at 08:51 AM 0
Share

Actually I want to display like this :

alt text

screen-shot-2016-04-08-at-22047-pm.png (50.4 kB)

1 Reply

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

Answer by troien · Apr 08, 2016 at 09:02 AM

Ok.. So to be clear, you want the orange/brown buttons to not have gaps between them?

If so:

  1. Check the 'spacing' of the horizontal layout group (You should set it to 0). This should remove any gaps between the buttons.

  2. Check the 'child force expand' in the horizontal layout group (or check flexible width for all the buttons). This should stretch the buttons to fill the horizontal layout group.

If after step 1 you still have gaps between your buttons, then this is most likely caused by a transparent border around the sprite you used. You could fix that by selecting a sprite without a transparent border or perhaps by setting the spacing to a value lower then 0...

Comment
Add comment · Show 5 · 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 siddharth3322 · Apr 08, 2016 at 09:07 AM 0
Share

This is parent object inspector data : alt text

screen-shot-2016-04-08-at-23443-pm.png (48.3 kB)
avatar image siddharth3322 · Apr 08, 2016 at 09:07 AM 0
Share

$$anonymous$$ay be Layout Element affect in this!!!

avatar image siddharth3322 · Apr 08, 2016 at 09:08 AM 0
Share

Ask me what other details you want?

avatar image troien · Apr 08, 2016 at 09:14 AM 0
Share

Well, it looks like your settings of the layout group are correct. So the only thing that I believe could be wrong here is the sprite/texture/image you use for the buttons. If this sprite has transparent borders, then when you place them next to each other, these transparent borders will create a gap between your buttons like I said in my answer. Try making a sprite without transparent borders and use that, or set the 'spacing' to a value lower then 0 (how much lower I don't know, that depends on the width of the transparent border)

avatar image siddharth3322 · Apr 08, 2016 at 09:22 AM 0
Share

For this your all opinions are correct. But in my one this mistake exist. Actual parent get scale to fit width but sprite exist in to child object and that was also set with center anchor position. Following image gives you more idea.

alt text

So I applied full stretched setting to all child images and problem get solved.

screen-shot-2016-04-08-at-24909-pm.png (33.8 kB)

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

65 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

Related Questions

Subclassing Button, public variable won't show up in the inspector 5 Answers

Unity 5 WebGL Facebook SDK UI Button Sharing not Working 0 Answers

UI cycling through my level select levels 1 Answer

a function is working on editor but not working on android divice 1 Answer

Change scene and play it by clicking UI Button? Scene does just load but not start playmode? 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