質問編集履歴
1
スクリプトを改変しエラーをなくしました。
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -16,13 +16,14 @@
|
|
|
16
16
|
using UnityEngine;
|
|
17
17
|
using UnityEngine.UI;
|
|
18
18
|
|
|
19
|
-
public class
|
|
19
|
+
public class FlashController : MonoBehaviour
|
|
20
20
|
{
|
|
21
|
+
private Image img;
|
|
21
22
|
// Start is called before the first frame update
|
|
22
23
|
void Start()
|
|
23
24
|
{
|
|
24
25
|
GameObject img = GameObject.Find("Image");
|
|
25
|
-
img.color = Color
|
|
26
|
+
img.GetComponent<Image>().color = new Color (1f, 1f, 1f, 0f);
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
// Update is called once per frame
|
|
@@ -32,17 +33,17 @@
|
|
|
32
33
|
{
|
|
33
34
|
if (collision.gameObject.tag == "W")
|
|
34
35
|
{
|
|
35
|
-
img.color = new Color(0.5f, 0f, 0f, 0.5f);
|
|
36
|
+
img.GetComponent<Image>().color = new Color(0.5f, 0f, 0f, 0.5f);
|
|
36
37
|
}
|
|
37
38
|
else
|
|
38
39
|
{
|
|
39
|
-
img.color = Color.Lerp(img.color, Color.clear, Time.deltaTime);
|
|
40
|
+
img.GetComponent<Image>().color = Color.Lerp(img.color, Color.clear, Time.deltaTime);
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
|
-
|
|
45
45
|
```
|
|
46
|
-
しかし "The name "img" does not exist in the current context.とエラー表示されてしまいます。
|
|
47
46
|
|
|
47
|
+
無事compileできるのですが、画面が赤くフラッシュしません。
|
|
48
|
+
|
|
48
49
|
どこがおかしいか、またスクリプトをどう描き直したらよいか、ご教示頂けますと幸甚です。
|