teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

編集

2020/08/14 02:52

投稿

tsuki01
tsuki01

スコア1751

answer CHANGED
@@ -2,16 +2,14 @@
2
2
  スクショのGameObjectとコード比較しましたが、以下GameObject名の指定が誤ってないでしょうか。
3
3
 
4
4
  ```C#
5
- // 上段:誤、 下段:正
6
5
  // ※GameObject側とコード側で、スペルの大文字小文字が異なっている("t"が違っている)
7
6
  // ※GameObject側では"Text"がついているのに、コード側では抜けている
8
- Text1 = GameObject.Find("LongTapTime").GetComponent<Text>();
7
+ 誤: Text1 = GameObject.Find("LongTapTime").GetComponent<Text>();
9
- Text1 = GameObject.Find("LongtapTimeText").GetComponent<Text>();
8
+ 正: Text1 = GameObject.Find("LongtapTimeText").GetComponent<Text>();
10
9
 
11
- // 上段:誤、 下段:正
12
10
  // ※"Count"の大文字小文字がGameObjectと異なっている
13
- Text3 = GameObject.Find("clearCount").GetComponent<Text>();
11
+ 誤: Text3 = GameObject.Find("clearCount").GetComponent<Text>();
14
- Text3 = GameObject.Find("clearcount").GetComponent<Text>();
12
+ 正: Text3 = GameObject.Find("clearcount").GetComponent<Text>();
15
13
  ```
16
14
 
17
15
  ---

1

追記

2020/08/14 02:52

投稿

tsuki01
tsuki01

スコア1751

answer CHANGED
@@ -12,4 +12,9 @@
12
12
  // ※"Count"の大文字小文字がGameObjectと異なっている
13
13
  Text3 = GameObject.Find("clearCount").GetComponent<Text>();
14
14
  Text3 = GameObject.Find("clearcount").GetComponent<Text>();
15
- ```
15
+ ```
16
+
17
+ ---
18
+
19
+ **補足**
20
+ 他の方からのコメントにもありますが、各GameObjectに"Text"コンポーネントがアタッチされているかもご確認ください。