質問編集履歴
1
ソースコード変更いたしました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -133,3 +133,135 @@
|
|
133
133
|
どなたかご教授いただけますと大変助かります。
|
134
134
|
|
135
135
|
ご確認の程よろしくお願い致します。
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
※補足
|
146
|
+
|
147
|
+
2つのコードをつなぎ合わせたものです。
|
148
|
+
|
149
|
+
エラーはなく、クリックしても音声もならず、シーン遷移も行いません。
|
150
|
+
|
151
|
+
ご確認の程よろしくお願い致します。
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
------------------------------------------------------
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
'''
|
160
|
+
|
161
|
+
//シーン切り替え
|
162
|
+
|
163
|
+
using UnityEngine;
|
164
|
+
|
165
|
+
using System.Collections;
|
166
|
+
|
167
|
+
using UnityEngine.SceneManagement;// ←new!
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
//---------------------------------------------------
|
174
|
+
|
175
|
+
//===================================================
|
176
|
+
|
177
|
+
public class test : MonoBehaviour {
|
178
|
+
|
179
|
+
GameObject obj;
|
180
|
+
|
181
|
+
int counter = 0;
|
182
|
+
|
183
|
+
private readonly string NEXT_SCENE_NAME = "1";
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
// AudioSourceはInspectorでセット.
|
192
|
+
|
193
|
+
// かつAudioClipもInspectorでAudioSourceにアタッチ済みであること前提.
|
194
|
+
|
195
|
+
[SerializeField] private AudioSource audio = null;
|
196
|
+
|
197
|
+
[SerializeField ] private AudioClip clip = null;
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
//---------------------------------------------------
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
void Update () {
|
208
|
+
|
209
|
+
if (Input.GetMouseButtonDown (0)) {
|
210
|
+
|
211
|
+
Vector3 pos = Input.mousePosition;
|
212
|
+
|
213
|
+
Ray ray = Camera.main.ScreenPointToRay (pos);
|
214
|
+
|
215
|
+
RaycastHit hit;
|
216
|
+
|
217
|
+
if (Physics.Raycast (ray, out hit, 100f)) {
|
218
|
+
|
219
|
+
obj = hit.collider.gameObject;
|
220
|
+
|
221
|
+
counter = 100;
|
222
|
+
|
223
|
+
}
|
224
|
+
|
225
|
+
}
|
226
|
+
|
227
|
+
}
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
//---------------------------------------------------
|
232
|
+
|
233
|
+
// コルーチンで次のシーンへ遷移.
|
234
|
+
|
235
|
+
private IEnumerator changeScene(){
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
this.audio.PlayOneShot( this.clip );
|
240
|
+
|
241
|
+
//this.audio.PlayOneShot( this.audio.clip );
|
242
|
+
|
243
|
+
while ( this.audio.isPlaying ){
|
244
|
+
|
245
|
+
yield return new WaitForSeconds( 1.0f );
|
246
|
+
|
247
|
+
}
|
248
|
+
|
249
|
+
SceneManager.LoadScene( this.NEXT_SCENE_NAME );
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
yield return null;
|
254
|
+
|
255
|
+
}
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
}
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
'''
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
-------------------------------------------------------------------------
|