-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sound.cs
39 lines (34 loc) · 817 Bytes
/
Sound.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using UnityEngine;
public class Sound : MonoBehaviour
{
public AudioClip rainingThunder;
public AudioClip lightningStrike;
// Use this for initialization
void Awake()
{
audio.clip = rainingThunder;
audio.Play();
audio.loop = true;
}
// Update is called once per frame
void Update ()
{
if (Input.GetMouseButton(0))
{
if (audio.clip == rainingThunder)
{
audio.loop = false;
audio.clip = lightningStrike;
audio.volume = 0.2F;
audio.Play();
audio.volume = 1;
}
}
if (!audio.isPlaying)
{
audio.clip = rainingThunder;
audio.loop = true;
audio.Play();
}
}
}