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 RecyclingBen · Jul 05, 2017 at 08:39 PM · ui

UI elements rounding position to parent gameobject

Hello,

I've been working on a game and one annoying thing I've found is that when I moved a gameobject that is a parent to, say, a button, when I moved the parent gamobject the child button seems to snap in to place when I move it, as if it were snapping on to a grid.

Now while I'll mention that I'm working with small numbers, they aren't astronomically low (I'm working with coordinates at or below 1)

It's not easily noticeable, but I'm trying to get the position of the parent gameobject just right (it's a pause button that I'm putting on the top-right corner) and so it would make sense that I wouldn't want the pause button to be slightly off of the position.

Can anyone lend me some help on this?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Jwizard93 · Jul 05, 2017 at 10:17 PM

If the child object is meant to be in the same place as the parent object then make sure the child's location is 0,0,0. Child transforms are relative to their parent.

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 RecyclingBen · Jul 06, 2017 at 01:50 PM 0
Share

Well yeah, that's the problem.

I have a normal gameobject and a UI element. The UI element is child to the parent gameobject. Let's say I put the gameobject's position to 0,0,0. and then the UI element to the same area.

Now let's say I put the gameobject to 0, 0.5, 0. The UI element's position is still 0,0,0. But, when I move the gameobject to 0,2,0, the UI element suddenly jumps up to something like 0,1.5,0.

Basically what I'm saying is the UI element is acting as if it is snapping to a grid. I don't get the same results when the child object is just another normal gameobject.

avatar image Jwizard93 RecyclingBen · Jul 06, 2017 at 03:25 PM 0
Share

Of course, my mistake.

So now I'm thinking maybe it's an anchors thing. There should be a component of the UI elements called RectTransform. That component should have public fields called anchors. Adjusting those anchors adjusts how the UI element reacts to properties of its parent gameObject. Have you tried playing around with that? I found that info here in this list of tweets. There's a lot more comprehensive UI tut out there, but this seems a good place to learn the key words you need to know about.

Unity Tip Website

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

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

Related Questions

How to update UI Text color in EditMode? 0 Answers

How do I create an Exit confirmation Pop up when I click the exit button? 4 Answers

PNG Sprite scaling issues 1 Answer

4.6 UI Canvas is smaller than normal 1 Answer

Call AddListener on sibling components from MonoBehaviour.Reset 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