[游戏开发][Unity]TextMeshPro切换中日文字体

 [游戏开发][Unity]TextMeshPro切换中日文字体_第1张图片

[游戏开发][Unity]TextMeshPro切换中日文字体_第2张图片

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]TextMeshPro切换中日文字体_第3张图片

就是Unity序列化的Asset文件,这个文件可以在编辑器中加载,也可以打包到assetbundle中加载

你可能感兴趣的:(开发心得,unity,游戏引擎)