質問編集履歴
1
コードの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -26,14 +26,6 @@
|
|
26
26
|
|
27
27
|
```C#
|
28
28
|
|
29
|
-
using System.Collections;
|
30
|
-
|
31
|
-
using System.Collections.Generic;
|
32
|
-
|
33
|
-
using UnityEngine;
|
34
|
-
|
35
|
-
|
36
|
-
|
37
29
|
public class PresentGenerator : MonoBehaviour
|
38
30
|
|
39
31
|
{
|
@@ -46,7 +38,13 @@
|
|
46
38
|
|
47
39
|
|
48
40
|
|
41
|
+
public int count; //インスタンスしている数
|
42
|
+
|
43
|
+
public int max; //インスタンスできる最大数
|
44
|
+
|
45
|
+
|
46
|
+
|
49
|
-
|
47
|
+
public float xMinPosition; //X座標の最小値
|
50
48
|
|
51
49
|
public float xMaxPosition; //X座標の最大値
|
52
50
|
|
@@ -56,7 +54,23 @@
|
|
56
54
|
|
57
55
|
|
58
56
|
|
57
|
+
// Start is called before the first frame update
|
58
|
+
|
59
|
+
void Start()
|
60
|
+
|
61
|
+
{}
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
// Update is called once per frame
|
66
|
+
|
67
|
+
void Update()
|
68
|
+
|
69
|
+
{}
|
70
|
+
|
71
|
+
|
72
|
+
|
59
|
-
private Vector2 GetRandomPosition()
|
73
|
+
private Vector2 GetRandomPosition()
|
60
74
|
|
61
75
|
{
|
62
76
|
|
@@ -74,25 +88,31 @@
|
|
74
88
|
|
75
89
|
}
|
76
90
|
|
77
|
-
void Presentor()
|
91
|
+
void Presentor()
|
78
92
|
|
79
93
|
{
|
80
94
|
|
81
|
-
|
95
|
+
if (count < max)
|
82
96
|
|
97
|
+
{
|
98
|
+
|
99
|
+
GameObject Present = Instantiate(P1) as GameObject; //P1を生成する
|
100
|
+
|
83
|
-
Present.transform.position = GetRandomPosition(); //生成するアイテムの位置をランダムに設定する
|
101
|
+
Present.transform.position = GetRandomPosition(); //生成するアイテムの位置をランダムに設定する
|
84
102
|
|
85
103
|
|
86
104
|
|
87
|
-
GameObject Present2 = Instantiate(P2) as GameObject; //P2を生成する
|
105
|
+
GameObject Present2 = Instantiate(P2) as GameObject; //P2を生成する
|
88
106
|
|
89
|
-
Present2.transform.position = GetRandomPosition(); //生成するアイテムの位置をランダムに設定する
|
107
|
+
Present2.transform.position = GetRandomPosition(); //生成するアイテムの位置をランダムに設定する
|
90
108
|
|
91
109
|
|
92
110
|
|
93
|
-
GameObject Present3 = Instantiate(P3) as GameObject; //P3を生成する
|
111
|
+
GameObject Present3 = Instantiate(P3) as GameObject; //P3を生成する
|
94
112
|
|
95
|
-
Present3.transform.position = GetRandomPosition(); //生成するアイテムの位置をランダムに設定する
|
113
|
+
Present3.transform.position = GetRandomPosition(); //生成するアイテムの位置をランダムに設定する
|
114
|
+
|
115
|
+
}
|
96
116
|
|
97
117
|
}
|
98
118
|
|