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 (a and b) and 1 image .
I created an 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
Inside a Android Device (here I uploaded the image from BlueStacks , I didn't use my mobile)
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 (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:)