質問編集履歴
5
あ
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
raycast unity color
|
test
CHANGED
File without changes
|
4
a
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
raycast unity color
|
1
|
+
araycast unity color
|
test
CHANGED
@@ -142,8 +142,6 @@
|
|
142
142
|
|
143
143
|
using UnityEngine;
|
144
144
|
|
145
|
-
using Vuforia;
|
146
|
-
|
147
145
|
using System;
|
148
146
|
|
149
147
|
public class vbScript : MonoBehaviour{
|
@@ -226,11 +224,7 @@
|
|
226
224
|
|
227
225
|
case 2 :
|
228
226
|
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
227
|
+
gamemadefaultMaterial[2].GetComponent<MeshRenderer> ().material.color = Color.blue;
|
234
228
|
|
235
229
|
break ;
|
236
230
|
|
3
ああ
test
CHANGED
File without changes
|
test
CHANGED
@@ -129,3 +129,257 @@
|
|
129
129
|
}
|
130
130
|
|
131
131
|
```
|
132
|
+
|
133
|
+
変更後
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
```C#
|
138
|
+
|
139
|
+
using System.Collections;
|
140
|
+
|
141
|
+
using System.Collections.Generic;
|
142
|
+
|
143
|
+
using UnityEngine;
|
144
|
+
|
145
|
+
using Vuforia;
|
146
|
+
|
147
|
+
using System;
|
148
|
+
|
149
|
+
public class vbScript : MonoBehaviour{
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
GameObject[] virtualButtonObject = new GameObject[3];
|
154
|
+
|
155
|
+
GameObject[] _3Dtext = new GameObject[3];
|
156
|
+
|
157
|
+
public TextMesh[] _3DtextInstance = new TextMesh[3];
|
158
|
+
|
159
|
+
Renderer[] virtualButtonMaterial = new Renderer[3];
|
160
|
+
|
161
|
+
int mask = 1 << 8;
|
162
|
+
|
163
|
+
public sample sampleClass;
|
164
|
+
|
165
|
+
GameObject[] gamemadefaultMaterial = new GameObject[3];
|
166
|
+
|
167
|
+
public static int timeSchedulleCount =1 ;
|
168
|
+
|
169
|
+
int colorFlag ;
|
170
|
+
|
171
|
+
void Start () {
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
_3DtextInstance [0].text = "1";
|
176
|
+
|
177
|
+
StartCoroutine ("colorWait");
|
178
|
+
|
179
|
+
}
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
// Update is called once per frame
|
184
|
+
|
185
|
+
void Update () {
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
OnColliderTouchedtouch ();
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
}
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
public IEnumerator colorWait(){
|
198
|
+
|
199
|
+
yield return new WaitForSeconds (2.0f);
|
200
|
+
|
201
|
+
try{
|
202
|
+
|
203
|
+
switch (colorFlag){
|
204
|
+
|
205
|
+
case 0:
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
gamemadefaultMaterial [0].GetComponent<MeshRenderer> ().material.color = Color.blue;
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
break;
|
214
|
+
|
215
|
+
case 1 :
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
gamemadefaultMaterial[1].GetComponent<MeshRenderer> ().material.color = Color.blue;
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
break;
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
case 2 :
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
gamemadefaultMaterial[2].GetComponent<MeshRenderer> ().material.color = Color.blue;
|
234
|
+
|
235
|
+
break ;
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
}
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
}catch(NullReferenceException ex){
|
244
|
+
|
245
|
+
}
|
246
|
+
|
247
|
+
}
|
248
|
+
|
249
|
+
public void OnColliderTouchedtouch(){
|
250
|
+
|
251
|
+
if (Input.GetMouseButtonDown(0)){
|
252
|
+
|
253
|
+
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
254
|
+
|
255
|
+
RaycastHit hit;
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
try{
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
if (Physics.Raycast (ray, out hit, Mathf.Infinity, mask)) {
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
switch (hit.collider.name) {
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
case "actionButton0":
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
hit.collider.GetComponent<MeshRenderer> ().material.color = Color.yellow;
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
if (timeSchedulleCount < 6)
|
282
|
+
|
283
|
+
timeSchedulleCount++;
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
_3DtextInstance [0].text = timeSchedulleCount + "";
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
gamemadefaultMaterial[0] = hit.collider.gameObject ;
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
colorFlag =0 ;
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
colorWait() ;
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
break;
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
case "actionButton1":
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
hit.collider.GetComponent<MeshRenderer> ().material.color = Color.yellow ;
|
312
|
+
|
313
|
+
gamemadefaultMaterial[1] = hit.collider.gameObject ;
|
314
|
+
|
315
|
+
colorFlag =1 ;
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
colorWait();
|
320
|
+
|
321
|
+
break;
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
case "actionButton2":
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
hit.collider.GetComponent<MeshRenderer> ().material.color = Color.yellow;
|
330
|
+
|
331
|
+
gamemadefaultMaterial[2] = hit.collider.gameObject ;
|
332
|
+
|
333
|
+
if (timeSchedulleCount > 1)
|
334
|
+
|
335
|
+
timeSchedulleCount--;
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
_3DtextInstance [0].text = timeSchedulleCount + "";
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
colorFlag =2 ;
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
colorWait();
|
348
|
+
|
349
|
+
break;
|
350
|
+
|
351
|
+
}
|
352
|
+
|
353
|
+
}
|
354
|
+
|
355
|
+
}catch(NullReferenceException e){
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
}
|
360
|
+
|
361
|
+
|
362
|
+
|
363
|
+
}else {
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
try{
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
}catch(NullReferenceException ex){
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
}
|
376
|
+
|
377
|
+
}
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
}
|
382
|
+
|
383
|
+
}
|
384
|
+
|
385
|
+
```
|
2
あ
test
CHANGED
File without changes
|
test
CHANGED
@@ -46,6 +46,16 @@
|
|
46
46
|
|
47
47
|
|
48
48
|
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
gamemadefaultMaterial[0] = hit.collider.gameObject ;
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
49
59
|
break;
|
50
60
|
|
51
61
|
|
@@ -56,7 +66,7 @@
|
|
56
66
|
|
57
67
|
hit.collider.GetComponent<MeshRenderer> ().material.color = Color.blue;
|
58
68
|
|
59
|
-
|
69
|
+
gamemadefaultMaterial[1] = hit.collider.gameObject ;
|
60
70
|
|
61
71
|
break;
|
62
72
|
|
@@ -68,7 +78,9 @@
|
|
68
78
|
|
69
79
|
hit.collider.GetComponent<MeshRenderer> ().material.color = Color.yellow;
|
70
80
|
|
81
|
+
gamemadefaultMaterial[2] = hit.collider.gameObject ;
|
71
82
|
|
83
|
+
|
72
84
|
|
73
85
|
break;
|
74
86
|
|
1
あ
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
raycastを飛ばして
|
2
2
|
|
3
|
-
当たったオブジェクトの色を変え、2秒程度したら元の色に戻すという処理を実装したいのですが2秒とどめてまたも
|
3
|
+
当たったオブジェクトの色を変え、2秒程度したら元の色に戻すという処理を実装したいのですが2秒とどめてまたもとに戻すという処理がどのように書けばいいかわかりません。
|
4
4
|
|
5
5
|
解決策などあるでしょうか?
|
6
6
|
|
@@ -68,10 +68,6 @@
|
|
68
68
|
|
69
69
|
hit.collider.GetComponent<MeshRenderer> ().material.color = Color.yellow;
|
70
70
|
|
71
|
-
gamemadefaultMaterial[2] = hit.collider.gameObject ;
|
72
|
-
|
73
|
-
|
74
|
-
|
75
71
|
|
76
72
|
|
77
73
|
break;
|