質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.46%
Unity

Unityは、Unity Technologiesが開発・販売している、IDEを内蔵するゲームエンジンです。主にC#を用いたプログラミングでコンテンツの開発が可能です。

Q&A

0回答

657閲覧

unity textmeshで文字のフォントをスクリプトで変更させたい

hikadesuyon_

総合スコア5

Unity

Unityは、Unity Technologiesが開発・販売している、IDEを内蔵するゲームエンジンです。主にC#を用いたプログラミングでコンテンツの開発が可能です。

0グッド

0クリップ

投稿2020/12/06 08:25

unity初心者です。

text meshを用いて文字を表示させて、その文字のフォントを変更したいです。
表示はうまくいきましたが、フォントの変更はうまくいきません。

フォントはアセットストアからインポートしたfontファイルの中にあるフォントを利用したいです。

コードは以下の通りです。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class textmeshtest : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
Font font = Resources.Load<Font> ("Fonts/MPlustestflight63a");
GetComponent<TextMesh>().text = "Hello world";
GetComponent<TextMesh>.font = font;

} // Update is called once per frame void Update() { }

}

エラー内容は以下の通りです。
Assets/textmeshtest.cs(12,9): error CS0119: 'Component.GetComponent<T>()' is a method, which is not valid in the given context

All compiler errors have to be fixed before you can enter playmode!
UnityEditor.SceneView:ShowCompileErrorNotification()

All compiler errors have to be fixed before you can enter playmode!
UnityEditor.SceneView:ShowCompileErrorNotification()

All compiler errors have to be fixed before you can enter playmode!
UnityEditor.SceneView:ShowCompileErrorNotification()

All compiler errors have to be fixed before you can enter playmode!
UnityEditor.SceneView:ShowCompileErrorNotification()

unity詳しい方どなたか返答お願いいたします。。。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.46%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問