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
3
Question by sybixsus · Feb 21, 2010 at 02:04 AM · sizefontlabel

Changing Button/Label text size?

The game I'm working on is designed for 1920x1080 and automatically scales to whatever resolution you're running it at. Naturally for 1920x1080, I need a fairly big font (32 point seems to work nicely) but if someone is running at 640x480, a 32 point font is far, far too big. Now I can't possibly load a different font for every possible resolution out there, but I can't find a way to adjust text size either. This seems pretty elementary. Presumably fonts are loaded into a texture, and drawn from the texture. So there should not be any speed hit from scaling them, and I can scale everything else which is drawn from a texture, but I can't find the trick for fonts.

Surely there's a solution for this. People can't be having enormous fonts on very low resolutions, or vice versa.

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

Answer by lollevel · Feb 21, 2010 at 02:37 AM

I remember something about resizing the fonts of GUI on the 3rd person plataform tutorial's pdf here at page 55, that's achieved by using a transform matrix.

example from GameHUD.js from tutorial:

    // Our GUI is laid out for a 1920 x 1200 pixel display (16:10 aspect). 
    //The next line makes sure it rescales nicely to other resolutions.
    GUI.matrix = Matrix4x4.TRS (Vector3(0, 0, 0), 
    Quaternion.identity, Vector3 (Screen.height / nativeVerticalResolution, 
    Screen.height / nativeVerticalResolution, 1));

Hope it helps :)

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 sybixsus · Feb 22, 2010 at 11:41 PM 0
Share

A very creative solution, and with a lot of other possibilities too. Thanks very much for that.

avatar image
2

Answer by Eric5h5 · Feb 21, 2010 at 03:39 AM

If you're using a GUIText object rather than OnGUI, it's trivial to use text that scales automatically, by unchecking "pixel correct" and adjusting the X and Y scale as desired.

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 sybixsus · Feb 22, 2010 at 11:42 PM 0
Share

I hadn't really looked at GUIText objects until now. Ideally, I did want a button in this instance, for the added benefits of keeping everything within the GUI system. Nevertheless, GUIText objects could definitely have their uses as well, so thanks for introducing me to them.

avatar image Hakimo · Apr 27, 2011 at 03:30 AM 0
Share

I noticed that by unchecking "pixel correct", the font can look blurry. I guess that's the drawback from what I noticed.

avatar image Eric5h5 · Apr 27, 2011 at 03:32 AM 0
Share

@Hakimo: import the font at a sufficiently large size, so it will have enough resolution to be not blurry.

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

No one has followed this question yet.

Related Questions

Changing the size of a GUI label 1 Answer

How to set the font size in GUI.Label 2 Answers

Changing a GUILabel text SIZE 3 Answers

multi line label with different font? 1 Answer

Why does my non-dynamic label text not resize in Android? 2 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