質問編集履歴

1

コードが間違っていました

2020/04/16 04:55

投稿

poporonn
poporonn

スコア13

test CHANGED
File without changes
test CHANGED
@@ -6,17 +6,25 @@
6
6
 
7
7
  ```c#
8
8
 
9
+
10
+
9
11
  using System.Collections;
10
12
 
11
13
  using System.Collections.Generic;
12
14
 
13
15
  using UnityEngine;
14
16
 
17
+ using System.Threading.Tasks;
15
18
 
19
+ using UnityEngine.UI;
16
20
 
17
- public class toru : MonoBehaviour
21
+ public class Item : MonoBehaviour
18
22
 
19
23
  {
24
+
25
+ public Text scoretext;
26
+
27
+ private int score = 0;
20
28
 
21
29
  // Start is called before the first frame update
22
30
 
@@ -32,25 +40,19 @@
32
40
 
33
41
  // Update is called once per frame
34
42
 
35
- void Update()
36
-
37
- {
38
-
39
-
40
-
41
- }
42
-
43
43
  private void OnCollisionEnter(Collision collision)
44
44
 
45
45
  {
46
46
 
47
- if (collision.gameObject.tag == "Item")
47
+ if (collision.gameObject.tag == "Untagged")
48
48
 
49
49
  {
50
50
 
51
- GetComponent<Sinu>().enabled = false;
51
+ score += 1;
52
52
 
53
-
53
+ scoretext.text = string.Format("Score;[0]", score);
54
+
55
+ Destroy(this.gameObject);
54
56
 
55
57
  }
56
58
 
@@ -58,6 +60,4 @@
58
60
 
59
61
  }
60
62
 
61
-
62
-
63
63
  ```