テキスト関連

Unity C#

ローカライズ

テキストのローカライズ
以下のコードをオブジェクトにアタッチ

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class TextChange : MonoBehaviour
{
    public Text text;
    public string nihonngo;
    public string eigo;

    // Start is called before the first frame update
    void Start()
    {

        if (Application.systemLanguage == SystemLanguage.Japanese)
        {
            text.GetComponent<Text>().text = nihonngo;
        }
        else
        {
            text.GetComponent<Text>().text = eigo;
        }

    }

}

変換したいテキストオブジェクトをアタッチ
文字列を入力

ゲーム開始時に対象のテキストが変換される

テキストにフチをつける

outlineコンポーネントをテキストにアタッチ

テキストを変更する

using UnityEngine.UI;

public class textTest : MonoBehaviour
{
    public Text test;

    // Start is called before the first frame update
    void Start()
    {
        test.text = "test";
    }

}

Start関数でボタンのテキストが変更される

コメント

タイトルとURLをコピーしました