SubtitleResizer.cs
490 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using UnityEngine;
using UnityEngine.UI;
public class SubtitleResizer : MonoBehaviour {
protected void Start ()
{
Text text = gameObject.GetComponent<Text>();
if (Screen.dpi < 140)
{
text.fontSize = 20;
}
// 240
else if (Screen.dpi < 280)
{
text.fontSize = 38;
}
// 320
else if (Screen.dpi < 400)
{
text.fontSize = 56;
}
// 480
else if (Screen.dpi < 500)
{
text.fontSize = 76;
}
else
{
text.fontSize = 56;
}
}
}