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 varunstorm · Dec 27, 2013 at 11:11 AM · sizefontdisplay

How to increase font size of text displayed

I have a code snippet that displays some text on the screen. Is there any way to increase the font size and the font itself

This is the display code-

 public var mess: String = "Hello";
     
     function OnGUI() 
     }
         GUI.Label (Rect (10, 30, 1000, 20),"Word: " +mess);
     }
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
0

Answer by Eric5h5 · Dec 27, 2013 at 11:13 AM

Make a GUIStyle where the fontSize is the desired size and use that style in the label.

 var myStyle : GUIStyle;
Comment
Add comment · Show 5 · 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 varunstorm · Dec 27, 2013 at 11:23 AM 0
Share

can u give me a code example for this

avatar image varunstorm · Dec 27, 2013 at 11:26 AM 0
Share

Can u give me an example code to do this

avatar image ShadoX · Dec 27, 2013 at 01:45 PM 0
Share
 GUIStyle style = new GUIStyle();
 style.fontSize = 130;
 GUI.Label (new Rect (10, 10, 100, 20), "text", style);

Adjust the other style variables to your liking as it seems to use black color by default (it's usually white)

avatar image varunstorm · Dec 28, 2013 at 05:21 AM 0
Share

Dear ShadoX

When I do this the result is

alt text

Why is the text displayed twice

Is there something I missed

PS: I have changed the value of the variable "mess"

avatar image ShadoX · Jan 04, 2014 at 11:06 AM 0
Share

Sorry, the picture isn't working for me, could you upload it again? Perhaps you have "GUI.Label(.." twice somewhere?

avatar image
0

Answer by sath · Jan 04, 2014 at 12:46 PM

Also you can do this:

 var textStyle : GUIStyle ; //change settings from inspector
 var mess : String = "Hello";
 var resizeFont : float = 0.2;//change this to resize font (min=0,01 - max=0,5)
 
     
 function OnGUI(){
     //FONT RESIZE
     textStyle.fontSize=Mathf.RoundToInt(Screen.height * resizeFont);
     
     GUI.Label (Rect (10, 30, 1000, 20),"Word: " + mess , textStyle);
 }
Comment
Add comment · 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

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

20 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

Related Questions

How to change the font and size of a text in a gui box? 1 Answer

Change GUI Font Size Dynamically? 1 Answer

How can I to make my Font size bigger than 72? 2 Answers

gui button vary font size 1 Answer

GUIBox fontSize without changing other labels? 3 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