「Unity/TMPro/Text」の版間の差分
提供: 初心者エンジニアの簡易メモ
(→2DのTMProのテキストをスクリプトで入れる) |
|||
(同じ利用者による、間の5版が非表示) | |||
行4: | 行4: | ||
#(サンプルを使いたい場合)Window/TextMeshPro/Import TMP Example and Extras | #(サンプルを使いたい場合)Window/TextMeshPro/Import TMP Example and Extras | ||
− | ==2DのTMProのテキストをスクリプトで入れる( | + | ==2DのTMProのテキストをスクリプトで入れる(uGUI)== |
<pre> | <pre> | ||
using TMPro; | using TMPro; | ||
行30: | 行30: | ||
</pre> | </pre> | ||
− | == | + | ==色変更== |
− | + | textPro.text = "<color=#F1F1F1>□</color>"; | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | < | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | </ | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + |
2023年1月8日 (日) 13:02時点における最新版
2DのTMProのテキストを追加
- ヒエラルキーで右クリックで、UI/TextMeshProを追加
- Window/TextMeshPro/Import TMP Essential Resources
- (サンプルを使いたい場合)Window/TextMeshPro/Import TMP Example and Extras
2DのTMProのテキストをスクリプトで入れる(uGUI)
using TMPro; public class SampleScene : MonoBehaviour { void Start() { TextMeshProUGUI textPro = GameObject.Find("Text (TMP)").GetComponent<TextMeshProUGUI>(); textPro.text = "hoge"; } }
2DのTMProのテキストをスクリプトで入れる(通常)
using TMPro; public class SampleScene : MonoBehaviour { void Start() { TextMeshPro textPro = GameObject.Find("Text (TMP)").GetComponent<TextMeshPro>(); textPro.text = "hoge"; } }
色変更
textPro.text = "<color=#F1F1F1>□</color>";