Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Hoffa25 · Apr 27, 2015 at 11:29 PM · uitextresize

Resize all UI texts fontsize in a scene with one command?

I have several hundreds of UI texts in my 2D game. Having used the new UI system all trough the game looks the same on all devises apart from two things that I would like to fix in a time effective way. The first is the font sizes. Of course I could drag all of them to my game object in inspector and attach a script telling every text to resize accordingly to resolution ov the device. ...or is it a way to call ALL text.fontsize in a scene at awake() without having to drag in inspector?

I have the sam problem with the built in UI shadow scripts that I have attached to everything (including all text). I want to be able to resize them in a elegant way aswell.

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
2
Best Answer

Answer by Xarbrough · Apr 28, 2015 at 10:30 AM

If you'd really really want to you could find all UnityEngine.UI.Text components with FindObjectsOfType(), but this will totally kill your performance at runtime if you have a lot of text objects.

API reference FindObjectsOfType

The better solution would be to make use of the dynamic scaling abilities of the new UI. There's the Canvas Scaler, Content Size Fitter and Layout Group with Layout Element. Text can also have Best Fit with min and max size. This in conjunction with correct anchoring should give you a scalable UI. See: Unity Manual HowTo Design for Multiple Resolutions

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 Hoffa25 · Apr 28, 2015 at 10:38 AM 0
Share

Ok thanks! $$anonymous$$y intention is to resize all texts and shadows at startup.. It shouldnt take much time..? And after that it shouldnt take any off my performance, right?

Everything in my UI resizes perfectly exept texts and shadows... I have found out the hard way that Best Fit lags my game terribly, and there is also very difficult to get the same size of the text in different text fields, buttons etc.

Im gonna have a look at the link you sent now.

avatar image Hoffa25 · Apr 28, 2015 at 11:04 AM 0
Share

Canvas scaler did the trick for me! I changed it from "constant pixel size" to "scale with screen size".

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How to understand if 4.6 UI button is highlighted? 3 Answers

UI: Loading the text in a Text type with a String? 1 Answer

Why are my Unity UI fonts rendering incorrectly? 4 Answers

Help Changing GUI Text size 0 Answers

Measure text size for UI Text 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