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 NicolusBuck · Jan 10, 2016 at 05:48 AM · unity 5guitextfont

Unity GUI Font Size changes with the screen resolution Problem

I am working on a project and now I have a problem . The problem is the font size. The font size is OK inside the Unity but it is really small when I play the game on a real Android device .

My Canvas has 2 text and 1 image .

I created a empty game object to hold that text.

Here is the code attached to empty game object :-

 using UnityEngine;
 using System.Collections;
 using UnityEngine.UI;
 
 
 public class Text_Script : MonoBehaviour 
 {
 
 public Text My_Text_1 ;
 public Text My_Text_2 ;
 
 // Use this for initialization
 void Start () 
 {
     My_Text_1.text = "Hello";
     My_Text_2.text = "World";
 }
 
 // Update is called once per frame
 void Update () 
 {
 
 }
 }


Here are the images :-

Inside Unity alt text

Inside a Android Device (here I uploaded the image from BlueStacks , I didn't use my mobile) alt text

So why this is happening ?

I tried this :-

 function Start() 
 {
      var myText = GetComponent(GUIText);
      // 50 is the fontsize you want to use
      myText.fontSize = Mathf.Min(screen.height,screen.width)/50;
 }


but I don't know where to put and on which object should I put those code And I am using Unity 5 and that code is for Unity 4.x .

I don't want to scale the font for a large size as explained in YouTube video (https://www.youtube.com/watch?v=_9mOh7_xX2o) (I don't think this is a good method)

So is there any ways to change the font size according to the screen size and resolution .

Please help me

Thanks:)

unity.png (19.8 kB)
bluestacks.png (24.0 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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by LazyElephant · Jan 10, 2016 at 08:14 AM

You don't need to fix this in script. If you position the anchors for your Text objects properly, your text will scale based on the screen resolution. In fact, on that video description, he links to another video that explains how to do it with the new GUI elements.

https://www.youtube.com/watch?v=svyDgYz5idg

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Using Japanese in my game 1 Answer

TextMeshPro Set Alpha Color 0 Answers

UTF-8 UI Text problem 2 Answers

Modals for 3D Objects/Environment 0 Answers

Modal Dialog for a 3D Environment/Object [SOLVED] 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