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
4
Question by Kamil1064 · Apr 11, 2016 at 06:21 PM · uilayoutanchorgrids

Grid layout group changing anchors

Hi, I have got plenty of buttons as childs of mainButton, they are disabled before start and via script I'm enabling them. Problem is In mainButton object when I'm using Grid Layout Group, it's changing all child's Anchors to left up, i want to middle center, actually to make Grid Layout Group not changing that. I would like to not set up them via script because it will make a lot of changing in all code. Is there way to disable that function on Grid Layout Group, or maybe I should use something different? alt text

unity-grid-layout-group-01.jpg (170.0 kB)
Comment
Add comment · Show 6
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 troien · Apr 11, 2016 at 07:16 PM 0
Share

Small question, why do you want the child anchors to be middle center? Because a grid layout group places it's childs on a grid on a fixed position and with a fixed size (starting in a given corner and on a given axis), anchors could in theory be set to anything but there is really no point as changing it would just cause the grid layout group to calculate the new x, y position and size values in order to place the child at exactly the same position... Because there is no point in wasting time to calculate that I would understand why it is set to a fixed corner. So what are you hoping to achieve by changing the anchor?

avatar image Kamil1064 troien · Apr 11, 2016 at 07:25 PM 0
Share

I'm taking at start theirs positions, then moving them somewhere, at end check if they back correctly. On screen everything is ok but values are different because anchors changes so position values too.

avatar image troien Kamil1064 · Apr 12, 2016 at 09:24 AM 1
Share

Ok, so because I'm still not able to graps why you want to do this, I'll just try to answer the original question, in the hope it helps you...

You are not able to change the anchors of the childs to middle center easilly. You could in theory make a script that extends GridLayoutGroup and overwrite the methods that set the anchors. (SetlayoutHorizontal) But you then would probably have to overwrite a lot more as the whole component assumes the anchors to be in the left top. If you want to do that, the source of GridLayoutGroup which is publically available is a good start. At lines 121/122 the anchors are set.

You probably should use somethng different. But because I don't know what the ultimate goal is of doing all the things you do here, I can't hep you with that...

Show more comments

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.

Follow this Question

Answers Answers and Comments

57 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

Related Questions

How to Force a Layout Group to Rebuild 0 Answers

Anchored Positions of horizontal layout element children not set during Start Function. 1 Answer

Is it possible to the anchor points for a child of a layout group so that the anchor is not automatically top left? 0 Answers

Stretching 90° rotated RectTransform to the size of the Canvas 0 Answers

Questions about UGUI Rect Transform Anchors. How to make UI objects scale, correctly, with screen? 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