回答編集履歴

2

GameControllerについて記述を追記しました。

2021/09/26 12:52

投稿

YOshim
YOshim

スコア1085

test CHANGED
@@ -31,3 +31,11 @@
31
31
  ```
32
32
 
33
33
  ちなみに`bool _isPlaying`の`_isPlaying`は変数名なのでなんでもよいです。
34
+
35
+
36
+
37
+ 追記:
38
+
39
+ 回答を見てなんでそれで上手くいくのか理解できず調べましたが、
40
+
41
+ `GameController`というスクリプトはオブジェクトにアタッチせずプロジェクト内で共有できる特別なものなんですね、初めて知りました。

1

コードを追記

2021/09/26 12:52

投稿

YOshim
YOshim

スコア1085

test CHANGED
@@ -22,4 +22,12 @@
22
22
 
23
23
  bool _isPlaying = GameObject.Find("GameController").GetComponent<GameController>().isPlaying;
24
24
 
25
+
26
+
27
+ //PlayerスクリプトではgameController = GameObject.Find("GameController");の記述があるので以下でもOK
28
+
29
+ bool _isPlaying = gameController.GetComponent<GameController>().isPlaying;
30
+
25
31
  ```
32
+
33
+ ちなみに`bool _isPlaying`の`_isPlaying`は変数名なのでなんでもよいです。