質問編集履歴
5
あ
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
|
1
|
+
raycast unity color
|
body
CHANGED
File without changes
|
4
a
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
|
1
|
+
araycast unity color
|
body
CHANGED
@@ -70,7 +70,6 @@
|
|
70
70
|
using System.Collections;
|
71
71
|
using System.Collections.Generic;
|
72
72
|
using UnityEngine;
|
73
|
-
using Vuforia;
|
74
73
|
using System;
|
75
74
|
public class vbScript : MonoBehaviour{
|
76
75
|
|
@@ -112,9 +111,7 @@
|
|
112
111
|
break;
|
113
112
|
|
114
113
|
case 2 :
|
115
|
-
|
116
|
-
|
117
|
-
|
114
|
+
gamemadefaultMaterial[2].GetComponent<MeshRenderer> ().material.color = Color.blue;
|
118
115
|
break ;
|
119
116
|
|
120
117
|
}
|
3
ああ
title
CHANGED
File without changes
|
body
CHANGED
@@ -63,4 +63,131 @@
|
|
63
63
|
}
|
64
64
|
|
65
65
|
}
|
66
|
+
```
|
67
|
+
変更後
|
68
|
+
|
69
|
+
```C#
|
70
|
+
using System.Collections;
|
71
|
+
using System.Collections.Generic;
|
72
|
+
using UnityEngine;
|
73
|
+
using Vuforia;
|
74
|
+
using System;
|
75
|
+
public class vbScript : MonoBehaviour{
|
76
|
+
|
77
|
+
GameObject[] virtualButtonObject = new GameObject[3];
|
78
|
+
GameObject[] _3Dtext = new GameObject[3];
|
79
|
+
public TextMesh[] _3DtextInstance = new TextMesh[3];
|
80
|
+
Renderer[] virtualButtonMaterial = new Renderer[3];
|
81
|
+
int mask = 1 << 8;
|
82
|
+
public sample sampleClass;
|
83
|
+
GameObject[] gamemadefaultMaterial = new GameObject[3];
|
84
|
+
public static int timeSchedulleCount =1 ;
|
85
|
+
int colorFlag ;
|
86
|
+
void Start () {
|
87
|
+
|
88
|
+
_3DtextInstance [0].text = "1";
|
89
|
+
StartCoroutine ("colorWait");
|
90
|
+
}
|
91
|
+
|
92
|
+
// Update is called once per frame
|
93
|
+
void Update () {
|
94
|
+
|
95
|
+
OnColliderTouchedtouch ();
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
public IEnumerator colorWait(){
|
100
|
+
yield return new WaitForSeconds (2.0f);
|
101
|
+
try{
|
102
|
+
switch (colorFlag){
|
103
|
+
case 0:
|
104
|
+
|
105
|
+
gamemadefaultMaterial [0].GetComponent<MeshRenderer> ().material.color = Color.blue;
|
106
|
+
|
107
|
+
break;
|
108
|
+
case 1 :
|
109
|
+
|
110
|
+
gamemadefaultMaterial[1].GetComponent<MeshRenderer> ().material.color = Color.blue;
|
111
|
+
|
112
|
+
break;
|
113
|
+
|
114
|
+
case 2 :
|
115
|
+
|
116
|
+
|
117
|
+
gamemadefaultMaterial[2].GetComponent<MeshRenderer> ().material.color = Color.blue;
|
118
|
+
break ;
|
119
|
+
|
120
|
+
}
|
121
|
+
|
122
|
+
}catch(NullReferenceException ex){
|
123
|
+
}
|
124
|
+
}
|
125
|
+
public void OnColliderTouchedtouch(){
|
126
|
+
if (Input.GetMouseButtonDown(0)){
|
127
|
+
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
128
|
+
RaycastHit hit;
|
129
|
+
|
130
|
+
try{
|
131
|
+
|
132
|
+
if (Physics.Raycast (ray, out hit, Mathf.Infinity, mask)) {
|
133
|
+
|
134
|
+
|
135
|
+
switch (hit.collider.name) {
|
136
|
+
|
137
|
+
case "actionButton0":
|
138
|
+
|
139
|
+
hit.collider.GetComponent<MeshRenderer> ().material.color = Color.yellow;
|
140
|
+
|
141
|
+
if (timeSchedulleCount < 6)
|
142
|
+
timeSchedulleCount++;
|
143
|
+
|
144
|
+
_3DtextInstance [0].text = timeSchedulleCount + "";
|
145
|
+
|
146
|
+
gamemadefaultMaterial[0] = hit.collider.gameObject ;
|
147
|
+
|
148
|
+
colorFlag =0 ;
|
149
|
+
|
150
|
+
colorWait() ;
|
151
|
+
|
152
|
+
break;
|
153
|
+
|
154
|
+
case "actionButton1":
|
155
|
+
|
156
|
+
hit.collider.GetComponent<MeshRenderer> ().material.color = Color.yellow ;
|
157
|
+
gamemadefaultMaterial[1] = hit.collider.gameObject ;
|
158
|
+
colorFlag =1 ;
|
159
|
+
|
160
|
+
colorWait();
|
161
|
+
break;
|
162
|
+
|
163
|
+
case "actionButton2":
|
164
|
+
|
165
|
+
hit.collider.GetComponent<MeshRenderer> ().material.color = Color.yellow;
|
166
|
+
gamemadefaultMaterial[2] = hit.collider.gameObject ;
|
167
|
+
if (timeSchedulleCount > 1)
|
168
|
+
timeSchedulleCount--;
|
169
|
+
|
170
|
+
_3DtextInstance [0].text = timeSchedulleCount + "";
|
171
|
+
|
172
|
+
colorFlag =2 ;
|
173
|
+
|
174
|
+
colorWait();
|
175
|
+
break;
|
176
|
+
}
|
177
|
+
}
|
178
|
+
}catch(NullReferenceException e){
|
179
|
+
|
180
|
+
}
|
181
|
+
|
182
|
+
}else {
|
183
|
+
|
184
|
+
try{
|
185
|
+
|
186
|
+
}catch(NullReferenceException ex){
|
187
|
+
|
188
|
+
}
|
189
|
+
}
|
190
|
+
|
191
|
+
}
|
192
|
+
}
|
66
193
|
```
|
2
あ
title
CHANGED
File without changes
|
body
CHANGED
@@ -22,18 +22,24 @@
|
|
22
22
|
|
23
23
|
hit.collider.GetComponent<MeshRenderer> ().material.color = Color.yellow;
|
24
24
|
|
25
|
+
|
26
|
+
|
27
|
+
gamemadefaultMaterial[0] = hit.collider.gameObject ;
|
28
|
+
|
29
|
+
|
25
30
|
break;
|
26
31
|
|
27
32
|
case "actionButton1":
|
28
33
|
|
29
34
|
hit.collider.GetComponent<MeshRenderer> ().material.color = Color.blue;
|
30
|
-
|
35
|
+
gamemadefaultMaterial[1] = hit.collider.gameObject ;
|
31
36
|
break;
|
32
37
|
|
33
38
|
case "actionButton2":
|
34
39
|
|
35
40
|
hit.collider.GetComponent<MeshRenderer> ().material.color = Color.yellow;
|
36
|
-
|
41
|
+
gamemadefaultMaterial[2] = hit.collider.gameObject ;
|
42
|
+
|
37
43
|
break;
|
38
44
|
}
|
39
45
|
|
1
あ
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
raycastを飛ばして
|
2
|
-
当たったオブジェクトの色を変え、2秒程度したら元の色に戻すという処理を実装したいのですが2秒とどめてまたも
|
2
|
+
当たったオブジェクトの色を変え、2秒程度したら元の色に戻すという処理を実装したいのですが2秒とどめてまたもとに戻すという処理がどのように書けばいいかわかりません。
|
3
3
|
解決策などあるでしょうか?
|
4
4
|
|
5
5
|
```C#
|
@@ -33,8 +33,6 @@
|
|
33
33
|
case "actionButton2":
|
34
34
|
|
35
35
|
hit.collider.GetComponent<MeshRenderer> ().material.color = Color.yellow;
|
36
|
-
gamemadefaultMaterial[2] = hit.collider.gameObject ;
|
37
|
-
|
38
36
|
|
39
37
|
break;
|
40
38
|
}
|