50 lines
881 B
C#
50 lines
881 B
C#
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
|
||
|
public class AudioManager : MonoBehaviour
|
||
|
{
|
||
|
public AudioSource musicSource;
|
||
|
public AudioSource sfxSource;
|
||
|
public List<MusicByTitle> musics = new List<MusicByTitle>();
|
||
|
|
||
|
public static AudioManager Instance;
|
||
|
|
||
|
|
||
|
private void Awake()
|
||
|
{
|
||
|
Instance = this;
|
||
|
}
|
||
|
|
||
|
public void ChangeMusic(MusicTitle _title)
|
||
|
{
|
||
|
musicSource.clip = musics.Find(x => x.title == _title).clip;
|
||
|
musicSource.Play();
|
||
|
}
|
||
|
|
||
|
public void StopMusic()
|
||
|
{
|
||
|
musicSource.Stop();
|
||
|
}
|
||
|
|
||
|
public void PlaySFX(AudioClip _clip)
|
||
|
{
|
||
|
sfxSource.PlayOneShot(_clip);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
[System.Serializable]
|
||
|
public class MusicByTitle
|
||
|
{
|
||
|
public MusicTitle title;
|
||
|
public AudioClip clip;
|
||
|
}
|
||
|
|
||
|
public enum MusicTitle
|
||
|
{
|
||
|
Menu,
|
||
|
TakingPicture,
|
||
|
VotingSession,
|
||
|
Ending
|
||
|
}
|