사운드 매니저 추가
This commit is contained in:
35
Gameton-06/Assets/Gameton/Scripts/Sound/SoundManager.cs
Normal file
35
Gameton-06/Assets/Gameton/Scripts/Sound/SoundManager.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TON
|
||||
{
|
||||
public class SoundManager : MonoBehaviour
|
||||
{
|
||||
public static SoundManager instance;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = this;
|
||||
DontDestroyOnLoad(instance);
|
||||
}
|
||||
else
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public void SFXPlay(string sfxName, AudioClip clip)
|
||||
{
|
||||
GameObject go = new GameObject(sfxName + "Sound");
|
||||
AudioSource audiosource = go.AddComponent<AudioSource>();
|
||||
|
||||
audiosource.clip = clip;
|
||||
audiosource.Play();
|
||||
|
||||
Destroy(go, clip.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Gameton-06/Assets/Gameton/Scripts/Sound/SoundManager.cs.meta
Normal file
11
Gameton-06/Assets/Gameton/Scripts/Sound/SoundManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 023ac119be3a3d24c816494653c341dc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user