回答編集履歴

4

ありません

2018/12/01 09:39

投稿

flan
flan

スコア146

test CHANGED
@@ -59,3 +59,13 @@
59
59
  ```
60
60
 
61
61
  ④[手法など 具体例](https://teratail.com/questions/140469)
62
+
63
+
64
+
65
+ 質問文に対して
66
+
67
+ 親クラスのGameObjectを子クラスから参照する方法が知りたい
68
+
69
+
70
+
71
+ unityはコンポーネント指向なので一般的なオブジェクト指向の考え方とは違うので、コンポーネントを参照する場合は親クラスから参照しても意味ないきがします

3

a

2018/12/01 09:39

投稿

flan
flan

スコア146

test CHANGED
@@ -6,6 +6,56 @@
6
6
 
7
7
  ③インスタンスを持たない変数からコンポーネントを取得しようとしているからです
8
8
 
9
+ 以下のように書き換えてください
10
+
11
+ ```ここに言語を入力
12
+
13
+ using System.Collections;
14
+
15
+ using System.Collections.Generic;
16
+
17
+ using UnityEngine;
18
+
19
+
20
+
21
+ public class MoveManager : GameManager {
22
+
23
+ float stageMoveSpeed = 0.01f;
24
+
25
+ Transform trMainCamera;
26
+
27
+ Vector3 posTrMainCamera;
28
+
29
+
30
+
31
+ private void Start()
32
+
33
+ {
34
+
35
+
36
+
37
+ trMainCamera = GetComponent<GameManager>().mainCamera.GetComponent<Transform>();
38
+
39
+ posTrMainCamera = trMainCamera.position;
40
+
41
+ }
42
+
43
+
44
+
45
+ void Update()
46
+
47
+ {
48
+
9
- ![![イメージ説明](449636b58ee44ae9e00bfcdec86f133a.png)
49
+ posTrMainCamera.x = posTrMainCamera.x + stageMoveSpeed;
50
+
51
+ trMainCamera.position = posTrMainCamera;
52
+
53
+ }
54
+
55
+ }
56
+
57
+
58
+
59
+ ```
10
60
 
11
61
  ④[手法など 具体例](https://teratail.com/questions/140469)

2

2018/12/01 09:29

投稿

flan
flan

スコア146

test CHANGED
@@ -1,13 +1,11 @@
1
- ①継承されたクラスのpublic変数は継承先にもアタッチ可能な仕様らしい
1
+ ①継承されたクラスのpublic変数は継承先にもアタッチ可能な仕様らしいです
2
2
 
3
- ②staticで初期化するので初期化のタイミングがわからなくなるため
3
+ ②staticで初期化するので初期化のタイミングがわからなくなるためです
4
4
 
5
5
  [参考](https://teratail.com/questions/26865)
6
6
 
7
- ッチきま。おそらく別のエラー
7
+ インスンスを持たない変数からコンポーネントを取得しようとしているからです
8
8
 
9
- エラー名を書くといいかもしれません
10
-
11
- ![![イメージ説明](449636b58ee44ae9e00bfcdec86f133a.png)(c5aa5d92ed12113142e0db67d7d93
9
+ ![![イメージ説明](449636b58ee44ae9e00bfcdec86f133a.png)
12
10
 
13
11
  ④[手法など 具体例](https://teratail.com/questions/140469)

1

2018/12/01 09:11

投稿

flan
flan

スコア146

test CHANGED
@@ -8,6 +8,6 @@
8
8
 
9
9
  エラー名を書くといいかもしれません
10
10
 
11
- ![![イメージ説明](449636b58ee44ae9e00bfcdec86f133a.png)](c5aa5d92ed12113142e0db67d7d936eb.png)
11
+ ![![イメージ説明](449636b58ee44ae9e00bfcdec86f133a.png)(c5aa5d92ed12113142e0db67d7d93
12
12
 
13
13
  ④[手法など 具体例](https://teratail.com/questions/140469)