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
0
Question by XtrainfiNIGHT · Jul 09, 2017 at 09:43 AM · unity 5uitextalignment

Text alignment not working

I am creating a game where I instantiate a prefab with a text component into a child of a canvas, and then edit the text variable. When I do so, the text doesn't appear where it should relative to its rectTransform and text alignment. Changing the alignment has no affect, although I can change the font and colour. I can also change the position with the rTrans position and pivot, as well as scale and rotation. This prefab works in other canvases that I have in the scene at the same time, but the troublesome canvas is the only one in Screen Space (Cam) render mode. If I add a prefab before i play it, it works properly. I use two different prefabs with different pivots, and text alignments only; both don't work. I have already implemented the function over a year ago, and it has worked as intended. It is only recently, when i was working on what I am pretty sure is unrelated, that this problem started, and I don't know what the cause is.alt text There are no other scripts attached to the texts other than what is on the image. There is a parent that changes scale but I didn't think it would cause the error as it has worked while using it.

problem.png (55.1 kB)
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

2 Replies

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

Answer by XtrainfiNIGHT · Jul 10, 2017 at 02:49 AM

I figured it out. In the texts' parent gameobject, I have a script that automatically changes scale to make sure that the puzzle stays on screen in the right position. Every Update frame it would calculate what scale it should be and then go: rectTransform.localScale = Vector3.one x scale; However, I was editing the script to take into account some side options and I ended making it rectTransform.localScale = Vector2.one x scale; (I think) this makes the z scale axis 0f, which caused the error. and if it didn't my game now works anyway.

Comment
Add comment · Show 1 · 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 XtrainfiNIGHT · Jul 10, 2017 at 02:51 AM 0
Share

I used "x" to symbolise the multiply symbol because it is in these text boxes to change style.

avatar image
0

Answer by UnityCoach · Jul 09, 2017 at 02:28 PM

I see position at x:25.86, y:76.1. You probably want to reset this to 0, 0, as your using a fixed anchor, the position behaves as a delta between parent and child pivot points.

Comment
Add comment · Show 3 · 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 XtrainfiNIGHT · Jul 09, 2017 at 11:43 PM 0
Share

There were many text objects near each other so I moved the one in the picture so it was isolated. The anchor and pivots are used for easy positioning as I instantiate the objects in a grid. The problem is that the visual text doesn't change position according to the text alignment (which is important so as the off center text is easily noticeable in a grid.alt text I know that what I am doing can work because it has for about a year.

example.png (15.6 kB)
avatar image UnityCoach XtrainfiNIGHT · Jul 10, 2017 at 02:26 AM 0
Share

I understand, but did you try resetting the position to 0, 0 ?

avatar image XtrainfiNIGHT UnityCoach · Jul 10, 2017 at 02:30 AM 0
Share

Yes. The position shouldn't be affecting it though, because both the text, and the sprites are all in the same parent.

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

205 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 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

Unity UI, Text glitch. 0 Answers

UTF-8 UI Text problem 2 Answers

Changing the UI Text 0 Answers

[SOLVED]My UI text don't update from script 3 Answers

How do I change UI button background AND button text on click(pressed)? 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