using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class LoadTTF : MonoBehaviour
{
public bool useJap;
public TextMeshProUGUI UI_Text;
public TMP_FontAsset chineseAsset;
public TMP_FontAsset japAsset;
// Start is called before the first frame update
void Start()
{
if (useJap)
{
UI_Text.font = japAsset;
UI_Text.text = "ござじずぜぞだぢづでどぱぴぷぺぽばびぶべぼらりるれろやゆよわァィゥヴェォカヵキクケコサシスセソタチツッテト";
}
else
{
UI_Text.font = chineseAsset;
UI_Text.text = "这是中文啊";
}
}
}
TMP_FontAsset
下图是github官方demo制作的7种语言字体,
就是Unity序列化的Asset文件,这个文件可以在编辑器中加载,也可以打包到assetbundle中加载
打AB包的时候记得要把字体文件放在公共资源位置
下图是我没有放公共位置的大小,引用字体的预设都把字体打包进去了
用工具可以查看包里为何这么大
把Font的Asset放到出包清单里
再次打包,所有UI预设都变小了。
随便拉一个AB包进来看看,发现没有字体相关的东西了。