[Game Development][Unity]TextMeshPro switches Chinese and Japanese fonts

 

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

 The picture below shows the 7 language fonts produced by the official github demo.

It is an Asset file serialized by Unity. This file can be loaded in the editor or packaged into an assetbundle for loading.

Guess you like

Origin blog.csdn.net/liuyongjie1992/article/details/134166240