質問編集履歴
1
ClickScript を書き換えました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,6 +24,14 @@
|
|
24
24
|
|
25
25
|
|
26
26
|
|
27
|
+
ClickScript を書き換え、上記のエラーは消えましたが
|
28
|
+
|
29
|
+
実行したときに、Nullrefarence と出ます(Startの部分がうまくいってないよう)
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
27
35
|
```C#
|
28
36
|
|
29
37
|
using System.Collections;
|
@@ -32,14 +40,154 @@
|
|
32
40
|
|
33
41
|
using UnityEngine;
|
34
42
|
|
43
|
+
|
44
|
+
|
45
|
+
public class clickScript : MonoBehaviour
|
46
|
+
|
47
|
+
{
|
48
|
+
|
49
|
+
int a;
|
50
|
+
|
51
|
+
int b;
|
52
|
+
|
53
|
+
devideScript script;
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
// Start is called before the first frame update
|
58
|
+
|
59
|
+
void Start()
|
60
|
+
|
61
|
+
{
|
62
|
+
|
63
|
+
a = script.devidednum;
|
64
|
+
|
65
|
+
b = script.devidenum;
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
// Update is called once per frame
|
72
|
+
|
73
|
+
void Update()
|
74
|
+
|
75
|
+
{
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
public void Onclickdevide()
|
84
|
+
|
85
|
+
{
|
86
|
+
|
87
|
+
if(a % b == 0)
|
88
|
+
|
89
|
+
{
|
90
|
+
|
91
|
+
Debug.Log("正解!");
|
92
|
+
|
93
|
+
}
|
94
|
+
|
95
|
+
else
|
96
|
+
|
97
|
+
{
|
98
|
+
|
99
|
+
Debug.Log("不正解!");
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
}
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
public void Onclickundevide()
|
110
|
+
|
111
|
+
{
|
112
|
+
|
113
|
+
if (a % b == 0)
|
114
|
+
|
115
|
+
{
|
116
|
+
|
117
|
+
Debug.Log("不正解!");
|
118
|
+
|
119
|
+
}
|
120
|
+
|
121
|
+
else
|
122
|
+
|
123
|
+
{
|
124
|
+
|
125
|
+
Debug.Log("正解!");
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
}
|
130
|
+
|
131
|
+
}
|
132
|
+
|
133
|
+
}
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
```
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
値を宣言したスクリプトはこちらです。
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
```C#
|
148
|
+
|
149
|
+
using System.Collections;
|
150
|
+
|
151
|
+
using System.Collections.Generic;
|
152
|
+
|
153
|
+
using UnityEngine;
|
154
|
+
|
35
155
|
using UnityEngine.UI;
|
36
156
|
|
37
157
|
using UnityEngine.SceneManagement;
|
38
158
|
|
159
|
+
|
160
|
+
|
39
|
-
public class
|
161
|
+
public class devideScript : MonoBehaviour
|
40
162
|
|
41
163
|
{
|
42
164
|
|
165
|
+
public int devidenum;
|
166
|
+
|
167
|
+
public int devidednum;
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
public int Correct = 0;
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
static float countup = 0.00f;
|
176
|
+
|
177
|
+
static bool T1 = true;
|
178
|
+
|
179
|
+
static Text timeText;
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
public Text devideText;
|
184
|
+
|
185
|
+
public Text devidedText;
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
public bool C1;
|
190
|
+
|
43
191
|
|
44
192
|
|
45
193
|
// Start is called before the first frame update
|
@@ -48,13 +196,13 @@
|
|
48
196
|
|
49
197
|
{
|
50
198
|
|
51
|
-
|
199
|
+
devidenum = UnityEngine.Random.Range(1,10);
|
52
|
-
|
200
|
+
|
53
|
-
|
201
|
+
devidednum = UnityEngine.Random.Range(10,40);
|
54
|
-
|
55
|
-
|
56
|
-
|
202
|
+
|
57
|
-
}
|
203
|
+
}
|
204
|
+
|
205
|
+
|
58
206
|
|
59
207
|
// Update is called once per frame
|
60
208
|
|
@@ -62,198 +210,64 @@
|
|
62
210
|
|
63
211
|
{
|
64
212
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
e
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
213
|
+
if (C1)
|
214
|
+
|
215
|
+
{
|
216
|
+
|
217
|
+
devidenum = UnityEngine.Random.Range(1, 10);
|
218
|
+
|
219
|
+
devidednum = UnityEngine.Random.Range(10, 40);
|
220
|
+
|
221
|
+
Correct = Correct + 1;
|
222
|
+
|
223
|
+
C1 = false;
|
224
|
+
|
225
|
+
}
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
string s1 = devidenum.ToString();
|
230
|
+
|
231
|
+
devideText.text = s1;
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
string s2 = devidednum.ToString();
|
236
|
+
|
237
|
+
devidedText.text = s2;
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
if (Correct >= 20)
|
242
|
+
|
243
|
+
{
|
244
|
+
|
245
|
+
T1 = false;
|
246
|
+
|
247
|
+
}
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
if (T1)
|
252
|
+
|
253
|
+
{
|
254
|
+
|
255
|
+
countup += Time.deltaTime;
|
256
|
+
|
257
|
+
}
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
timeText.text = countup.ToString("f2");
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
}
|
266
|
+
|
267
|
+
|
120
268
|
|
121
269
|
}
|
122
270
|
|
123
271
|
|
124
272
|
|
125
273
|
```
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
値を宣言したスクリプトはこちらです。
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
```C#
|
134
|
-
|
135
|
-
using System.Collections;
|
136
|
-
|
137
|
-
using System.Collections.Generic;
|
138
|
-
|
139
|
-
using UnityEngine;
|
140
|
-
|
141
|
-
using UnityEngine.UI;
|
142
|
-
|
143
|
-
using UnityEngine.SceneManagement;
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
public class devideScript : MonoBehaviour
|
148
|
-
|
149
|
-
{
|
150
|
-
|
151
|
-
public int devidenum;
|
152
|
-
|
153
|
-
public int devidednum;
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
public int Correct = 0;
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
static float countup = 0.00f;
|
162
|
-
|
163
|
-
static bool T1 = true;
|
164
|
-
|
165
|
-
static Text timeText;
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
public Text devideText;
|
170
|
-
|
171
|
-
public Text devidedText;
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
public bool C1;
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
// Start is called before the first frame update
|
180
|
-
|
181
|
-
void Start()
|
182
|
-
|
183
|
-
{
|
184
|
-
|
185
|
-
devidenum = UnityEngine.Random.Range(1,10);
|
186
|
-
|
187
|
-
devidednum = UnityEngine.Random.Range(10,40);
|
188
|
-
|
189
|
-
}
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
// Update is called once per frame
|
194
|
-
|
195
|
-
void Update()
|
196
|
-
|
197
|
-
{
|
198
|
-
|
199
|
-
if (C1)
|
200
|
-
|
201
|
-
{
|
202
|
-
|
203
|
-
devidenum = UnityEngine.Random.Range(1, 10);
|
204
|
-
|
205
|
-
devidednum = UnityEngine.Random.Range(10, 40);
|
206
|
-
|
207
|
-
Correct = Correct + 1;
|
208
|
-
|
209
|
-
C1 = false;
|
210
|
-
|
211
|
-
}
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
string s1 = devidenum.ToString();
|
216
|
-
|
217
|
-
devideText.text = s1;
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
string s2 = devidednum.ToString();
|
222
|
-
|
223
|
-
devidedText.text = s2;
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
if (Correct >= 20)
|
228
|
-
|
229
|
-
{
|
230
|
-
|
231
|
-
T1 = false;
|
232
|
-
|
233
|
-
}
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
if (T1)
|
238
|
-
|
239
|
-
{
|
240
|
-
|
241
|
-
countup += Time.deltaTime;
|
242
|
-
|
243
|
-
}
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
timeText.text = countup.ToString("f2");
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
}
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
}
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
```
|