質問編集履歴
1
質問を書き終わらずに投稿してしまったので、編集しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,4 +1,23 @@
|
|
1
1
|
#実現したいこと
|
2
|
-
下記のような
|
2
|
+
下記のような構造になっているPrefabを使用して、動的にアイテムを生成したい。その際にアイテム名を表すフォントを、そのアイテムに合わせてスクリプトから動的に変更したい。
|
3
3
|
--item
|
4
|
+
|-- itemName(Text) (⇦ これのフォントをスクリプトから動的に変更したい)
|
4
|
-
|--
|
5
|
+
|-- itemImage(Image)
|
6
|
+
|
7
|
+
#発生している問題
|
8
|
+
使用するフォントはUnity上にインポートしてあり、Inspetorから変更は可能になっている。
|
9
|
+
フォントファイルはAssets/Resources/Fonts以下に配置してあり、[こちらの手法](https://qiita.com/7of9/items/67c6607d0bcededf9034)を参考にして以下のように書いてみた。
|
10
|
+
|
11
|
+
```
|
12
|
+
Font font = Resources.GetBuiltinResource<Font>("Fonts/07LogoTypeGothic7.ttf");
|
13
|
+
itemName.font = font;
|
14
|
+
```
|
15
|
+
|
16
|
+
すると、以下の2つのエラーが出た。
|
17
|
+
```
|
18
|
+
Assertion failed:Failed to Find Fonts/07LogoTypeGothic7.ttf
|
19
|
+
The resource Fonts/07LogoTypeGothic7.ttf could not be loaded from the resource file!
|
20
|
+
```
|
21
|
+
|
22
|
+
このエラーを解決できる方や他の方法を知っている方がいましたらぜひご教授ください。
|
23
|
+
お願いします。
|