-
Notifications
You must be signed in to change notification settings - Fork 0
/
AudioManager.cs
42 lines (40 loc) · 1.26 KB
/
AudioManager.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
40
41
42
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Audio;
public class AudioManager : MonoBehaviour
{
// Start is called before the first frame update
static AudioManager current;
public AudioClip BgmClip;
public AudioClip putNumberClip;
public AudioMixerGroup mainMixer,numberMixer;
AudioSource BgmSource;
AudioSource NumberSource;
private void Awake() {
if(current != null)
{
Destroy(gameObject);
return;
}
current = this;
DontDestroyOnLoad(gameObject);
BgmSource = gameObject.AddComponent<AudioSource>();
NumberSource = gameObject.AddComponent<AudioSource>();
BgmSource.outputAudioMixerGroup = mainMixer;
NumberSource.outputAudioMixerGroup = numberMixer;
PlayBgm();
}
public static void PlayBgm(){
current.BgmSource.clip = current.BgmClip;
current.BgmSource.loop = true;
current.BgmSource.Play();
}
public static void PauseBgm(){
current.BgmSource.Pause();
}
public static void PlayPutNumberAudio(){
current.NumberSource.clip =current.putNumberClip;
current.NumberSource.Play();
}
}