質問編集履歴
1
情報の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -5,3 +5,73 @@
|
|
5
5
|
コインをとるとmp3が再生される
|
6
6
|
|
7
7
|
という風にしたいです。
|
8
|
+
|
9
|
+
参考にさせていただいたサイトはhttps://www.sejuku.net/blog/83535です。
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
### 発生している問題・エラーメッセージ
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
```
|
18
|
+
|
19
|
+
PlayOneShot was called with a null AudioClip.
|
20
|
+
|
21
|
+
UnityEngine.AudioSource:PlayOneShot (UnityEngine.AudioClip)
|
22
|
+
|
23
|
+
player:Update () (at Assets/player/player.cs:125)
|
24
|
+
|
25
|
+
```
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
### 該当のソースコード
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
```C#
|
34
|
+
|
35
|
+
public AudioClip sound1;
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
AudioSource audioSource;
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
(宣言)
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
```
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
```
|
52
|
+
|
53
|
+
audioSource = GetComponent<AudioSource>();
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
(GetComponent)
|
58
|
+
|
59
|
+
```
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
```
|
64
|
+
|
65
|
+
audioSource.PlayOneShot(sound1);
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
(再生)
|
70
|
+
|
71
|
+
```
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
### Unity 2020.2.1f1 Visual studio 2019
|