From 484705688ed6f463e23b0d23b733d1386128262c Mon Sep 17 00:00:00 2001 From: VirtueSky Date: Sat, 20 Jan 2024 01:00:04 +0700 Subject: [PATCH] Update AudioManager.cs --- VirtueSky/Audio/Runtime/AudioManager.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/VirtueSky/Audio/Runtime/AudioManager.cs b/VirtueSky/Audio/Runtime/AudioManager.cs index aefe33e3..57bca8d8 100644 --- a/VirtueSky/Audio/Runtime/AudioManager.cs +++ b/VirtueSky/Audio/Runtime/AudioManager.cs @@ -9,6 +9,7 @@ namespace VirtueSky.Audio { public class AudioManager : BaseMono { + [SerializeField] private bool isDontDestroyOnLoad; [Space] [SerializeField] private Pools pool; [SerializeField] private SoundComponent soundComponentPrefab; @@ -39,8 +40,11 @@ [Space] [Header("AudioManager Settings")] [SerializeField] private void Awake() { - DontDestroyOnLoad(this.gameObject); - pool.Initialize(); + if (isDontDestroyOnLoad) + { + DontDestroyOnLoad(this.gameObject); + } + sfxVolume.AddListener(OnSfxVolumeChanged); musicVolume.AddListener(OnMusicVolumeChanged); }