質問編集履歴
2
test
CHANGED
File without changes
|
test
CHANGED
@@ -44,7 +44,7 @@
|
|
44
44
|
|
45
45
|
```
|
46
46
|
|
47
|
-
|
47
|
+
```
|
48
48
|
|
49
49
|
C:\Users\アカウント名\Desktop\Unity\NagasakiUniv\Beatmaps/ futta-dream.wav
|
50
50
|
|
1
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,6 +2,60 @@
|
|
2
2
|
|
3
3
|
![イメージ説明](1b9ebf8d7a96a987753fb459de0ac468.png)
|
4
4
|
|
5
|
-
|
5
|
+
```
|
6
6
|
|
7
|
-
|
7
|
+
private IEnumerator LoadAudioFile(string filePath)
|
8
|
+
|
9
|
+
{
|
10
|
+
|
11
|
+
if (!File.Exists(filePath))
|
12
|
+
|
13
|
+
{
|
14
|
+
|
15
|
+
Debug.Log(filePath);
|
16
|
+
|
17
|
+
yield break;//ファイルが存在しなければ処理を行わない
|
18
|
+
|
19
|
+
}
|
20
|
+
|
21
|
+
var audioType = GetAudioType(filePath);//音源のフォーマット種別
|
22
|
+
|
23
|
+
//UnityWebRequestを用いて外部リソースを読み込む
|
24
|
+
|
25
|
+
using (var request = UnityWebRequestMultimedia.GetAudioClip("file:///" + filePath, audioType))
|
26
|
+
|
27
|
+
{
|
28
|
+
|
29
|
+
yield return request.SendWebRequest();
|
30
|
+
|
31
|
+
if(!request.isNetworkError)//エラーが発生しなかった場合
|
32
|
+
|
33
|
+
{
|
34
|
+
|
35
|
+
var audioClip = DownloadHandlerAudioClip.GetContent(request);//オーディオクリップを読み込み
|
36
|
+
|
37
|
+
audioSource.clip = audioClip;//audioSourceのclipに設定
|
38
|
+
|
39
|
+
}
|
40
|
+
|
41
|
+
}
|
42
|
+
|
43
|
+
}
|
44
|
+
|
45
|
+
```
|
46
|
+
|
47
|
+
エラーメッセージ
|
48
|
+
|
49
|
+
C:\Users\アカウント名\Desktop\Unity\NagasakiUniv\Beatmaps/ futta-dream.wav
|
50
|
+
|
51
|
+
UnityEngine.Debug:Log(Object)
|
52
|
+
|
53
|
+
<LoadAudioFile>d__13:MoveNext() (at Assets/Scripts/PlayerController.cs:92)
|
54
|
+
|
55
|
+
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
|
56
|
+
|
57
|
+
PlayerController:Awake() (at Assets/Scripts/PlayerController.cs:71)
|
58
|
+
|
59
|
+
```
|
60
|
+
|
61
|
+
大変失礼しました
|