Merge pull request #53 from Degulleo/DO-59-사운드-제어

DO-59 [Feat] 사운드 제어
This commit is contained in:
99jamin56 2025-03-26 15:55:19 +09:00 committed by GitHub
commit 40366ce4bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 158 additions and 450 deletions

Binary file not shown.

View File

@ -0,0 +1,23 @@
fileFormatVersion: 2
guid: 576c895328ccd5f4a91364f7fa42bea8
AudioImporter:
externalObjects: {}
serializedVersion: 7
defaultSettings:
serializedVersion: 2
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
preloadAudioData: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

View File

@ -10,7 +10,6 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 2402232447803946232} - component: {fileID: 2402232447803946232}
- component: {fileID: 3667565604047053759} - component: {fileID: 3667565604047053759}
- component: {fileID: 841089304725320238}
m_Layer: 0 m_Layer: 0
m_Name: Audio Manager m_Name: Audio Manager
m_TagString: Untagged m_TagString: Untagged
@ -46,103 +45,16 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
mainBgm: {fileID: 8300000, guid: 1d9c7fb20aa822c48933d00b6bd6a757, type: 3} mainBgm: {fileID: 8300000, guid: 1d9c7fb20aa822c48933d00b6bd6a757, type: 3}
gameBgm: {fileID: 8300000, guid: 6d4eda23943dd0b4099b86b28fa0840c, type: 3} gameBgm: {fileID: 8300000, guid: 576c895328ccd5f4a91364f7fa42bea8, type: 3}
clickSound: {fileID: 8300000, guid: cff2e6cf7f46a074d86955b3b6fd499a, type: 3} clickSound: {fileID: 8300000, guid: cff2e6cf7f46a074d86955b3b6fd499a, type: 3}
closeSound: {fileID: 8300000, guid: e7c0f32158a3e5b46bc3b59035aba898, type: 3} closeSound: {fileID: 8300000, guid: e7c0f32158a3e5b46bc3b59035aba898, type: 3}
sfxVolume: 0 coinsAddSound: {fileID: 8300000, guid: 1ec44182fa76a4b3eb1459c0a6d9a8ab, type: 3}
--- !u!82 &841089304725320238 coinsEmptySound: {fileID: 8300000, guid: 908a78cb991984977bea42916bed8684, type: 3}
AudioSource: coinsRemoveSound: {fileID: 8300000, guid: 585a9de0fb7ee4163af5c559ba5b2364, type: 3}
m_ObjectHideFlags: 0 winSound: {fileID: 8300000, guid: 1613a4bf934e4d043b4e50b1b74c16b5, type: 3}
m_CorrespondingSourceObject: {fileID: 0} loseSound: {fileID: 8300000, guid: 2a467daa72a01214384d2fa5677f668a, type: 3}
m_PrefabInstance: {fileID: 0} stoneSound: {fileID: 8300000, guid: 829ae38dccffa8f4ebf5829b8963ad31, type: 3}
m_PrefabAsset: {fileID: 0} bgmAudioSource: {fileID: 0}
m_GameObject: {fileID: 2946408323859178723} sfxVolume: 1
m_Enabled: 1 isPlayBGM: 0
serializedVersion: 4 isPlaySFX: 0
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4

View File

@ -10,7 +10,6 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 1769668775421633028} - component: {fileID: 1769668775421633028}
- component: {fileID: 4222531876603999234} - component: {fileID: 4222531876603999234}
- component: {fileID: 5499754916380040505}
m_Layer: 5 m_Layer: 5
m_Name: Coins Panel m_Name: Coins Panel
m_TagString: Untagged m_TagString: Untagged
@ -53,106 +52,6 @@ MonoBehaviour:
m_EditorClassIdentifier: m_EditorClassIdentifier:
coinsRemoveImageObject: {fileID: 4198953742281733827} coinsRemoveImageObject: {fileID: 4198953742281733827}
coinsCountText: {fileID: 2892066450466788586} coinsCountText: {fileID: 2892066450466788586}
coinsRemoveAudioClip: {fileID: 8300000, guid: 585a9de0fb7ee4163af5c559ba5b2364, type: 3}
coinsAddAudioClip: {fileID: 8300000, guid: 1ec44182fa76a4b3eb1459c0a6d9a8ab, type: 3}
coinsEmptyAudioClip: {fileID: 8300000, guid: 908a78cb991984977bea42916bed8684, type: 3}
ShopPanel: {fileID: 8190964574954487140, guid: eb257b0a685b2254f860f294ce8cba54, type: 3}
--- !u!82 &5499754916380040505
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 646100354038727038}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!1 &4198953742281733827 --- !u!1 &4198953742281733827
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -13,7 +13,6 @@ GameObject:
- component: {fileID: 5762671619601460934} - component: {fileID: 5762671619601460934}
- component: {fileID: 6789969287113785900} - component: {fileID: 6789969287113785900}
- component: {fileID: 413977444317235173} - component: {fileID: 413977444317235173}
- component: {fileID: 6428684691423417346}
m_Layer: 5 m_Layer: 5
m_Name: Switch m_Name: Switch
m_TagString: Untagged m_TagString: Untagged
@ -148,103 +147,6 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
handleImage: {fileID: 6756679498073114696} handleImage: {fileID: 6756679498073114696}
clickSound: {fileID: 8300000, guid: cff2e6cf7f46a074d86955b3b6fd499a, type: 3}
--- !u!82 &6428684691423417346
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 212417647848747046}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!1 &1754413034098038561 --- !u!1 &1754413034098038561
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -859,7 +761,6 @@ GameObject:
- component: {fileID: 2622934673103949083} - component: {fileID: 2622934673103949083}
- component: {fileID: 3464089222698319368} - component: {fileID: 3464089222698319368}
- component: {fileID: 8434701791193156984} - component: {fileID: 8434701791193156984}
- component: {fileID: 9145795730378986889}
m_Layer: 5 m_Layer: 5
m_Name: Switch m_Name: Switch
m_TagString: Untagged m_TagString: Untagged
@ -994,103 +895,6 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
handleImage: {fileID: 1822478720763898751} handleImage: {fileID: 1822478720763898751}
clickSound: {fileID: 8300000, guid: cff2e6cf7f46a074d86955b3b6fd499a, type: 3}
--- !u!82 &9145795730378986889
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5387157431517620447}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!1 &7654744771681034987 --- !u!1 &7654744771681034987
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

Binary file not shown.

View File

@ -0,0 +1,23 @@
fileFormatVersion: 2
guid: 1613a4bf934e4d043b4e50b1b74c16b5
AudioImporter:
externalObjects: {}
serializedVersion: 7
defaultSettings:
serializedVersion: 2
loadType: 0
sampleRateSetting: 0
sampleRateOverride: 44100
compressionFormat: 1
quality: 1
conversionMode: 0
preloadAudioData: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
loadInBackground: 0
ambisonic: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,5 +1,6 @@
using UnityEngine; using UnityEngine;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
using UnityEngine.Timeline;
public class AudioManager : Singleton<AudioManager> public class AudioManager : Singleton<AudioManager>
{ {
@ -9,11 +10,20 @@ public class AudioManager : Singleton<AudioManager>
[Header("SFX")] [Header("SFX")]
[SerializeField] private AudioClip clickSound; [SerializeField] private AudioClip clickSound;
[SerializeField] private AudioClip closeSound; [SerializeField] private AudioClip closeSound;
[SerializeField] private AudioClip coinsAddSound;
[SerializeField] private AudioClip coinsEmptySound;
[SerializeField] private AudioClip coinsRemoveSound;
[SerializeField] private AudioClip winSound;
[SerializeField] private AudioClip loseSound;
[SerializeField] private AudioClip stoneSound;
private AudioSource bgmAudioSource; // BGM을 위한 AudioSource [HideInInspector] public AudioSource bgmAudioSource; // BGM을 위한 AudioSource
private AudioSource sfxAudioSource; // SFX를 위한 AudioSource private AudioSource sfxAudioSource; // SFX를 위한 AudioSource
[HideInInspector] public float sfxVolume = 1.0f; // SFX 볼륨 (기본값 1) public float sfxVolume = 1.0f; // SFX 볼륨 (기본값 1)
[HideInInspector]public bool isPlayBGM;
[HideInInspector]public bool isPlaySFX;
private void Awake() private void Awake()
{ {
@ -27,10 +37,9 @@ public class AudioManager : Singleton<AudioManager>
// 시작 시 BGM을 자동으로 재생 // 시작 시 BGM을 자동으로 재생
private void Start() private void Start()
{ {
if (UserManager.IsPlayBGM) // UserManager의 BGM 설정값에 따라 BGM을 재생 isPlayBGM = UserManager.IsPlayBGM;
{ isPlaySFX = UserManager.IsPlaySFX;
PlayMainBGM(); // 기본 BGM을 재생 PlayBGM();
}
} }
// 메인 BGM을 재생하는 함수 // 메인 BGM을 재생하는 함수
@ -44,15 +53,6 @@ public class AudioManager : Singleton<AudioManager>
bgmAudioSource.Play(); // BGM 재생 bgmAudioSource.Play(); // BGM 재생
} }
} }
// BGM을 멈추는 함수
public void StopMainBGM()
{
if (bgmAudioSource != null && bgmAudioSource.isPlaying)
{
bgmAudioSource.Stop(); // BGM을 멈춤
}
}
public void PlayGameBGM() public void PlayGameBGM()
{ {
@ -64,18 +64,44 @@ public class AudioManager : Singleton<AudioManager>
bgmAudioSource.Play(); // 게임 BGM 재생 bgmAudioSource.Play(); // 게임 BGM 재생
} }
} }
public void PlayBGM()
{
if (isPlayBGM)
{
Scene currentScene = SceneManager.GetActiveScene();
if (currentScene.name == "Main")
{
StopBGM();
PlayMainBGM();
}
else if (currentScene.name == "Game")
{
StopBGM();
PlayGameBGM();
}
}
}
public void StopGameBGM() public void StopBGM()
{ {
if (bgmAudioSource != null && bgmAudioSource.isPlaying) if (bgmAudioSource != null && bgmAudioSource.isPlaying)
{ {
bgmAudioSource.Stop(); // 게임용 BGM을 멈춤 bgmAudioSource.Stop(); // 게임용 BGM을 멈춤
} }
} }
// 씬이 로드될 때마다 호출되는 OnSceneLoaded 메서드
protected override void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
PlayBGM();
}
// 클릭 사운드(SFX) 재생 // 클릭 사운드(SFX) 재생
public void PlayClickSound() public void PlayClickSound()
{ {
if (sfxAudioSource != null) if (sfxAudioSource != null)
{ {
sfxAudioSource.PlayOneShot(clickSound, sfxVolume); sfxAudioSource.PlayOneShot(clickSound, sfxVolume);
@ -91,26 +117,51 @@ public class AudioManager : Singleton<AudioManager>
} }
} }
// 씬이 로드될 때마다 호출되는 OnSceneLoaded 메서드 public void PlayCoinsAddSound()
protected override void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{ {
if (scene.name == "Main") if (isPlaySFX && sfxAudioSource!=null)
{ {
StopGameBGM(); sfxAudioSource.PlayOneShot(coinsAddSound, sfxVolume);
if (UserManager.IsPlayBGM) // BGM 설정값에 따라 메인 BGM을 재생
{
PlayMainBGM();
}
} }
else if (scene.name == "Game") }
public void PlayCoinsEmptySound()
{
if (isPlaySFX && sfxAudioSource!=null)
{ {
StopMainBGM(); sfxAudioSource.PlayOneShot(coinsEmptySound, sfxVolume);
}
if (UserManager.IsPlayBGM) // BGM 설정값에 따라 게임 BGM을 재생 }
{
PlayGameBGM(); public void PlayCoinsRemoveSound()
} {
if (isPlaySFX && sfxAudioSource!=null)
{
sfxAudioSource.PlayOneShot(coinsRemoveSound, sfxVolume);
}
}
public void PlayLoseSound()
{
if (isPlaySFX && sfxAudioSource!=null)
{
sfxAudioSource.PlayOneShot(loseSound, sfxVolume);
}
}
public void PlayWinSound()
{
if (isPlaySFX && sfxAudioSource!=null)
{
sfxAudioSource.PlayOneShot(winSound, sfxVolume);
}
}
public void PlayStoneSound()
{
if (isPlaySFX && sfxAudioSource!=null)
{
sfxAudioSource.PlayOneShot(stoneSound, sfxVolume);
} }
} }
} }

View File

@ -6,16 +6,11 @@ using UnityEngine.EventSystems;
using UnityEngine.Serialization; using UnityEngine.Serialization;
using UnityEngine.UI; using UnityEngine.UI;
[RequireComponent(typeof(AudioSource))]
public class CoinsPanelController : MonoBehaviour public class CoinsPanelController : MonoBehaviour
{ {
[SerializeField] private GameObject coinsRemoveImageObject; [SerializeField] private GameObject coinsRemoveImageObject;
[SerializeField] private TMP_Text coinsCountText; [SerializeField] private TMP_Text coinsCountText;
[SerializeField] private AudioClip coinsRemoveAudioClip;
[SerializeField] private AudioClip coinsAddAudioClip;
[SerializeField] private AudioClip coinsEmptyAudioClip;
private Color _coinsColor; private Color _coinsColor;
private AudioSource _audioSource; private AudioSource _audioSource;
private int _coinsCount; private int _coinsCount;
@ -110,19 +105,17 @@ public class CoinsPanelController : MonoBehaviour
{ {
ChangeTextAnimation(true, ()=> ChangeTextAnimation(true, ()=>
{ {
// TODO : 코인 수량 업데이트 _coinsCount += 500;
action?.Invoke(); action?.Invoke();
}); });
// 효과음 재생 // 효과음 재생
// TODO : if (UserInformation.IsPlaySFX) AudioManager.Instance.PlayCoinsAddSound();
_audioSource.PlayOneShot(coinsAddAudioClip);
}); });
sequence.AppendInterval(0.5f); sequence.AppendInterval(0.5f);
} }
sequence.OnComplete(() => sequence.OnComplete(() =>
{ {
_coinsCount += coinsCount; //추가된 코인 적용
_canvasGroup.blocksRaycasts = true; //구매 후 클릭 활성화 _canvasGroup.blocksRaycasts = true; //구매 후 클릭 활성화
}); });
} }
@ -130,8 +123,7 @@ public class CoinsPanelController : MonoBehaviour
public void EmptyCoins() public void EmptyCoins()
{ {
// 효과음 재생 // 효과음 재생
// TODO: if (UserInformation.IsPlaySFX) AudioManager.Instance.PlayCoinsEmptySound();
_audioSource.PlayOneShot(coinsEmptyAudioClip);
GetComponent<RectTransform>().DOPunchPosition(new Vector3(20f, 0, 0), 1f, 7); GetComponent<RectTransform>().DOPunchPosition(new Vector3(20f, 0, 0), 1f, 7);
} }
@ -151,8 +143,7 @@ public class CoinsPanelController : MonoBehaviour
} }
// 효과음 재생 // 효과음 재생
// TODO: if (UserInformation.IsPlaySFX) AudioManager.Instance.PlayCoinsRemoveSound();
_audioSource.PlayOneShot(coinsRemoveAudioClip);
// 코인 사라지는 연출 // 코인 사라지는 연출
coinsRemoveImageObject.SetActive(true); coinsRemoveImageObject.SetActive(true);

View File

@ -87,14 +87,22 @@ public class UserManager : Singleton<UserManager>
public static bool IsPlaySFX public static bool IsPlaySFX
{ {
get { return PlayerPrefs.GetInt("IsPlaySFX", 1) == 1; } get { return PlayerPrefs.GetInt("IsPlaySFX", 1) == 1; }
set { PlayerPrefs.SetInt("IsPlaySFX", value ? 1 : 0); } set
{
PlayerPrefs.SetInt("IsPlaySFX", value ? 1 : 0);
AudioManager.Instance.isPlaySFX = value;
}
} }
// 배경음악 재생 여부 // 배경음악 재생 여부
public static bool IsPlayBGM public static bool IsPlayBGM
{ {
get { return PlayerPrefs.GetInt("IsPlayBGM", 1) == 1; } get { return PlayerPrefs.GetInt("IsPlayBGM", 1) == 1; }
set { PlayerPrefs.SetInt("IsPlayBGM", value ? 1 : 0); } set
{
PlayerPrefs.SetInt("IsPlayBGM", value ? 1 : 0);
AudioManager.Instance.isPlayBGM = value;
}
} }
protected override void OnSceneLoaded(Scene scene, LoadSceneMode mode) protected override void OnSceneLoaded(Scene scene, LoadSceneMode mode)

View File

@ -6,11 +6,9 @@ using UnityEngine.UI;
using DG.Tweening; using DG.Tweening;
[RequireComponent(typeof(Image))] [RequireComponent(typeof(Image))]
[RequireComponent(typeof(AudioSource))]
public class SwitchController : MonoBehaviour public class SwitchController : MonoBehaviour
{ {
[SerializeField] private Image handleImage; [SerializeField] private Image handleImage;
[SerializeField] private AudioClip clickSound;
//스위치에 상태 변경 시 호출할 콜백 함수 //스위치에 상태 변경 시 호출할 콜백 함수
public delegate void OnSwitchChangedDelegate(bool isOn); public delegate void OnSwitchChangedDelegate(bool isOn);
@ -56,8 +54,7 @@ public class SwitchController : MonoBehaviour
} }
// 효과음 재생 // 효과음 재생
if (clickSound != null) AudioManager.Instance.PlayClickSound();
_audioSource.PlayOneShot(clickSound);
//이벤트 호출 //이벤트 호출
OnSwitchChanged?.Invoke(isOn); OnSwitchChanged?.Invoke(isOn);

View File

@ -33,15 +33,15 @@ public class SettingsPanelController : PanelController
// BGM을 끄는 경우 // BGM을 끄는 경우
if (!value) if (!value)
{ {
GameManager.Instance.audioManager.StopMainBGM(); // BGM을 끄기 AudioManager.Instance.StopBGM(); // BGM을 끄기
} }
// BGM을 켜는 경우 // BGM을 켜는 경우
else else
{ {
// 이미 BGM이 재생 중인 경우 새로 시작하지 않도록 체크 // 이미 BGM이 재생 중인 경우 새로 시작하지 않도록 체크
if (!GameManager.Instance.audioManager.GetComponent<AudioSource>().isPlaying) if (!AudioManager.Instance.bgmAudioSource.isPlaying)
{ {
GameManager.Instance.audioManager.PlayMainBGM(); // BGM을 켜기 AudioManager.Instance.PlayBGM(); // BGM을 켜기
} }
} }
} }