「Unity/TMPro/Text」の版間の差分
提供: 初心者エンジニアの簡易メモ
(ページの作成:「==サンプル== <pre> textobject.GetComponent<TextMeshProUGUI>(); textobject.text = "テストです"; </pre>」) |
|||
(同じ利用者による、間の18版が非表示) | |||
行1: | 行1: | ||
− | == | + | ==2DのTMProのテキストを追加== |
+ | #ヒエラルキーで右クリックで、UI/TextMeshProを追加 | ||
+ | #Window/TextMeshPro/Import TMP Essential Resources | ||
+ | #(サンプルを使いたい場合)Window/TextMeshPro/Import TMP Example and Extras | ||
+ | |||
+ | ==2DのTMProのテキストをスクリプトで入れる(uGUI)== | ||
<pre> | <pre> | ||
− | + | using TMPro; | |
− | + | public class SampleScene : MonoBehaviour | |
+ | { | ||
+ | void Start() | ||
+ | { | ||
+ | TextMeshProUGUI textPro = GameObject.Find("Text (TMP)").GetComponent<TextMeshProUGUI>(); | ||
+ | textPro.text = "hoge"; | ||
+ | } | ||
+ | } | ||
</pre> | </pre> | ||
+ | |||
+ | ==2DのTMProのテキストをスクリプトで入れる(通常)== | ||
+ | <pre> | ||
+ | using TMPro; | ||
+ | public class SampleScene : MonoBehaviour | ||
+ | { | ||
+ | void Start() | ||
+ | { | ||
+ | TextMeshPro textPro = GameObject.Find("Text (TMP)").GetComponent<TextMeshPro>(); | ||
+ | textPro.text = "hoge"; | ||
+ | } | ||
+ | } | ||
+ | </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>";