89 lines
2.5 KiB
C#
89 lines
2.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Threading;
|
|
using UnityEngine;
|
|
|
|
public class SoundManager : SingletonMonoBehaviour<SoundManager>
|
|
{
|
|
[SerializeField] AudioClip[] BackgroundMusic;
|
|
//[SerializeField] AudioClip[] ButtonSuond;
|
|
[SerializeField] AudioClip[] EftSuond;
|
|
float Backgroundvolume = 0.1f;
|
|
float Eftvolume = 0.3f;
|
|
public eBackgroundMusic NowMusic;
|
|
GameObject EftSound;
|
|
GameObjectPool<SoundBox> SoundList;
|
|
|
|
AudioSource BackGround;
|
|
public eBackgroundMusic NowPlayMusic//현재 재생중인 배경음악 정보를 넘겨줌
|
|
{
|
|
get { return NowMusic; }
|
|
}
|
|
public void ResetBackMusic(int Num)
|
|
{
|
|
|
|
}
|
|
public void PlayBack(eBackgroundMusic Num)
|
|
{
|
|
BackGround.clip = BackgroundMusic[(int)Num];
|
|
BackGround.mute = false;
|
|
BackGround.loop = true;
|
|
BackGround.volume = Backgroundvolume;
|
|
BackGround.Play();
|
|
NowMusic = Num;
|
|
}
|
|
protected override void OnAwake()
|
|
{
|
|
EftSound = (GameObject)Resources.Load("System/SoundBox");
|
|
BackGround = GetComponent<AudioSource>();
|
|
SoundList = new GameObjectPool<SoundBox>(15, () =>
|
|
{
|
|
var obj = Instantiate(EftSound) as GameObject;
|
|
obj.transform.SetParent(transform);
|
|
var Clone = obj.GetComponent<SoundBox>();
|
|
return Clone;
|
|
});
|
|
NowMusic = 0;
|
|
}
|
|
//public void StartSound(eButtonSuond Clip)
|
|
//{
|
|
// var obj = SoundList.pop();
|
|
// obj.gameObject.SetActive(true);
|
|
// obj.PlaySound(ButtonSuond[(int)Clip], Eftvolume);
|
|
//}
|
|
//public void StartSound(eButtonSuond Clip,Vector3 tr)
|
|
//{
|
|
// var obj = SoundList.pop();
|
|
// obj.gameObject.SetActive(true);
|
|
// obj.PlaySound(ButtonSuond[(int)Clip], Eftvolume, tr);
|
|
//}
|
|
public void StartSound(eEftSuond Clip)
|
|
{
|
|
var obj = SoundList.pop();
|
|
obj.gameObject.SetActive(true);
|
|
obj.PlaySound(EftSuond[(int)Clip], Eftvolume);
|
|
}
|
|
public void StartSound(eEftSuond Clip,Vector3 tr)
|
|
{
|
|
var obj = SoundList.pop();
|
|
obj.gameObject.SetActive(true);
|
|
obj.PlaySound(EftSuond[(int)Clip], Eftvolume, tr);
|
|
}
|
|
public void EndSound(SoundBox Box)
|
|
{
|
|
Box.gameObject.SetActive(false);
|
|
SoundList.push(Box);
|
|
}
|
|
public enum eBackgroundMusic
|
|
{
|
|
}
|
|
public enum eButtonSuond
|
|
{
|
|
}
|
|
public enum eEftSuond
|
|
{
|
|
TitleSound,
|
|
ButtonPop,
|
|
}
|
|
}
|