Merge branch 'main' into DEG-23-세이브-로드-로직-구현
This commit is contained in:
commit
89422a5f70
@ -1,24 +0,0 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
// PlayerStatsTest.ReadOnlyAttribute를 위한 에디터 속성 드로어
|
||||
[CustomPropertyDrawer(typeof(PlayerStatsTest.ReadOnlyAttribute))]
|
||||
public class ReadOnlyDrawer : PropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
// 이전 GUI 활성화 상태 저장
|
||||
bool wasEnabled = GUI.enabled;
|
||||
|
||||
// 필드 비활성화 (읽기 전용)
|
||||
GUI.enabled = false;
|
||||
|
||||
// 속성 그리기
|
||||
EditorGUI.PropertyField(position, property, label, true);
|
||||
|
||||
// GUI 활성화 상태 복원
|
||||
GUI.enabled = wasEnabled;
|
||||
}
|
||||
}
|
||||
#endif
|
@ -1,103 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerStatsTest : MonoBehaviour
|
||||
{
|
||||
[Header("현재 스탯")]
|
||||
[SerializeField, ReadOnly] private float currentTime;
|
||||
[SerializeField, ReadOnly] private float currentHealth;
|
||||
[SerializeField, ReadOnly] private float currentReputation;
|
||||
[SerializeField, ReadOnly] private int currentDay;
|
||||
|
||||
[Header("테스트 액션")]
|
||||
[Tooltip("액션을 선택하고 체크박스를 체크하여 실행")]
|
||||
[SerializeField] private ActionType actionToTest;
|
||||
[SerializeField] private bool executeAction;
|
||||
|
||||
// 컴포넌트 참조
|
||||
[Header("필수 참조")]
|
||||
[SerializeField] private PlayerStats playerStats;
|
||||
[SerializeField] private GameManager gameManager;
|
||||
|
||||
// ReadOnly 속성 (인스펙터에서 수정 불가능하게 만듦)
|
||||
public class ReadOnlyAttribute : PropertyAttribute { }
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// 참조 찾기 (없을 경우)
|
||||
if (playerStats == null)
|
||||
{
|
||||
playerStats = FindObjectOfType<PlayerStats>();
|
||||
Debug.Log("PlayerStats를 찾아 참조했습니다.");
|
||||
}
|
||||
|
||||
if (gameManager == null)
|
||||
{
|
||||
gameManager = FindObjectOfType<GameManager>();
|
||||
Debug.Log("GameManager를 찾아 참조했습니다.");
|
||||
}
|
||||
|
||||
// 초기 스탯 표시 업데이트
|
||||
UpdateStatsDisplay();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
// 매 프레임마다 스탯 업데이트
|
||||
UpdateStatsDisplay();
|
||||
|
||||
// 체크박스가 체크되면 선택된 액션 실행
|
||||
if (executeAction)
|
||||
{
|
||||
ExecuteSelectedAction();
|
||||
executeAction = false; // 체크박스 초기화
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateStatsDisplay()
|
||||
{
|
||||
// 참조 확인 후 스탯 업데이트
|
||||
if (playerStats != null)
|
||||
{
|
||||
currentTime = playerStats.TimeStat;
|
||||
currentHealth = playerStats.HealthStat;
|
||||
currentReputation = playerStats.ReputationStat;
|
||||
|
||||
// GameManager에서 날짜 정보 가져오기
|
||||
if (gameManager != null)
|
||||
{
|
||||
currentDay = gameManager.CurrentDay;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("GameManager 참조가 없습니다.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("PlayerStats 참조가 없습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
private void ExecuteSelectedAction()
|
||||
{
|
||||
if (playerStats != null)
|
||||
{
|
||||
// 선택한 액션 실행
|
||||
playerStats.PerformAction(actionToTest);
|
||||
UpdateStatsDisplay();
|
||||
Debug.Log($"액션 실행: {actionToTest}");
|
||||
|
||||
// 콘솔에 현재 스탯 정보 출력
|
||||
Debug.Log($"현재 스탯 - 시간: {currentTime}, 체력: {currentHealth}, 평판: {currentReputation}, 날짜: {currentDay}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("PlayerStats 참조가 없어 액션을 실행할 수 없습니다.");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:5a65e9dd60a7532ae1c4c43fda477ac0940c18c5c60f8a164b6fd52b9f1f4a42
|
||||
size 5196
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 533241c82a79dcc46932391bf865ce21
|
||||
guid: 3bf376b79225dd241aa996c1967947a1
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
@ -4,7 +4,7 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class GameManager : Singleton<GameManager>
|
||||
public partial class GameManager : Singleton<GameManager>
|
||||
{
|
||||
[SerializeField] private PlayerStats playerStats;
|
||||
|
||||
@ -20,6 +20,9 @@ public class GameManager : Singleton<GameManager>
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// 오디오 초기화
|
||||
InitializeAudio();
|
||||
|
||||
// PlayerStats의 하루 종료 이벤트 구독
|
||||
if (playerStats == null)
|
||||
{
|
@ -1,6 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 90448f678f8c503408de14c38cd7c653
|
||||
PrefabImporter:
|
||||
guid: 0dc4cdf0dfb7ed14cb56b18f7ff733f4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
184
Assets/Scripts/Common/GameUtility/GameSound.cs
Normal file
184
Assets/Scripts/Common/GameUtility/GameSound.cs
Normal file
@ -0,0 +1,184 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
// 게임 매니저의 오디오 관련 부분 클래스
|
||||
public partial class GameManager : Singleton<GameManager>
|
||||
{
|
||||
// 오디오 클립 참조
|
||||
[Header("오디오 설정")]
|
||||
[SerializeField] private AudioClip housingBGM;
|
||||
[SerializeField] private AudioClip dungeonBGM;
|
||||
[SerializeField] private AudioClip gameOverBGM;
|
||||
[SerializeField] private AudioClip victoryBGM;
|
||||
|
||||
[SerializeField] private AudioClip buttonClickSFX;
|
||||
|
||||
[Header("몬스터 효과음")]
|
||||
[SerializeField] private AudioClip monsterAttackSFX;
|
||||
[SerializeField] private AudioClip monsterDeathSFX;
|
||||
|
||||
// 씬에 따른 배경음 맵핑
|
||||
private Dictionary<string, AudioClip> sceneBGMMap = new Dictionary<string, AudioClip>();
|
||||
|
||||
// 현재 재생 중인 BGM 트랙
|
||||
private string currentBGMTrack = "";
|
||||
|
||||
// 오디오 관련 초기화
|
||||
private void InitializeAudio()
|
||||
{
|
||||
// 씬-BGM 맵핑 초기화
|
||||
sceneBGMMap.Clear();
|
||||
sceneBGMMap.Add("Housing", housingBGM); // 씬 이름, 해당 씬 BGM
|
||||
sceneBGMMap.Add("Game", dungeonBGM);
|
||||
|
||||
// 오디오 클립 등록 (초기화)
|
||||
if (SoundManager.Instance != null)
|
||||
{
|
||||
// BGM 등록
|
||||
if (housingBGM != null) SoundManager.Instance.LoadAudioClip("HousingBGM", housingBGM);
|
||||
if (dungeonBGM != null) SoundManager.Instance.LoadAudioClip("DungeonBGM", dungeonBGM);
|
||||
if (gameOverBGM != null) SoundManager.Instance.LoadAudioClip("GameOverBGM", gameOverBGM);
|
||||
if (victoryBGM != null) SoundManager.Instance.LoadAudioClip("VictoryBGM", victoryBGM);
|
||||
|
||||
// SFX 등록
|
||||
if (buttonClickSFX != null) SoundManager.Instance.LoadAudioClip("ButtonClick", buttonClickSFX);
|
||||
|
||||
// 몬스터 SFX 등록
|
||||
if (monsterAttackSFX != null) SoundManager.Instance.LoadAudioClip("MonsterAttack", monsterAttackSFX);
|
||||
if (monsterDeathSFX != null) SoundManager.Instance.LoadAudioClip("MonsterDeath", monsterDeathSFX);
|
||||
|
||||
// 저장된 볼륨 설정 로드
|
||||
// LoadVolumeSettings();
|
||||
|
||||
// 현재 씬에 맞는 배경음 재생
|
||||
// string currentSceneName = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name;
|
||||
// HandleSceneAudio(currentSceneName);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("SoundManager 인스턴스를 찾을 수 없습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
#region 볼륨 제어
|
||||
|
||||
// BGM 볼륨 설정 (0.0 ~ 1.0)
|
||||
public void SetVolumeBGM(float value)
|
||||
{
|
||||
if (SoundManager.Instance == null) return;
|
||||
|
||||
value = Mathf.Clamp01(value); // 혹시 모를 범위 제한
|
||||
SoundManager.Instance.SetBGMVolume(value);
|
||||
|
||||
// 설정 저장
|
||||
// PlayerPrefs.SetFloat("BGMVolume", value);
|
||||
// PlayerPrefs.Save();
|
||||
}
|
||||
|
||||
// SFX 볼륨 설정 (0.0 ~ 1.0)
|
||||
public void SetVolumeSFX(float value)
|
||||
{
|
||||
if (SoundManager.Instance == null) return;
|
||||
|
||||
value = Mathf.Clamp01(value);
|
||||
SoundManager.Instance.SetSFXVolume(value);
|
||||
|
||||
// 설정 저장
|
||||
// PlayerPrefs.SetFloat("SFXVolume", value);
|
||||
// PlayerPrefs.Save();
|
||||
}
|
||||
|
||||
// PlayerPrefs에 저장된 볼륨 설정 불러오기
|
||||
// private void LoadVolumeSettings()
|
||||
// {
|
||||
// float bgmVolume = PlayerPrefs.GetFloat("BGMVolume", 1.0f);
|
||||
// float sfxVolume = PlayerPrefs.GetFloat("SFXVolume", 1.0f);
|
||||
//
|
||||
// // 저장된 볼륨 설정 적용
|
||||
// if (SoundManager.Instance != null)
|
||||
// {
|
||||
// SoundManager.Instance.SetBGMVolume(bgmVolume);
|
||||
// SoundManager.Instance.SetSFXVolume(sfxVolume);
|
||||
// }
|
||||
// }
|
||||
|
||||
#endregion
|
||||
|
||||
// 씬에 따른 오디오 처리
|
||||
private void HandleSceneAudio(string sceneName)
|
||||
{
|
||||
if (SoundManager.Instance == null) return;
|
||||
|
||||
// 이미 같은 트랙이 재생 중이면 중복 재생하지 않음
|
||||
if (currentBGMTrack == sceneName) return;
|
||||
|
||||
// 씬에 맞는 BGM 재생
|
||||
if (sceneBGMMap.TryGetValue(sceneName, out AudioClip bgmClip))
|
||||
{
|
||||
if (bgmClip != null)
|
||||
{
|
||||
SoundManager.Instance.PlayBGM(bgmClip, true, 1.5f);
|
||||
currentBGMTrack = sceneName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region 배경음 제어 (게임 오버, 승리도 이쪽)
|
||||
|
||||
// 게임 오버 시 호출
|
||||
public void PlayGameOverMusic()
|
||||
{
|
||||
if (SoundManager.Instance == null) return;
|
||||
|
||||
if (gameOverBGM != null)
|
||||
{
|
||||
SoundManager.Instance.PlayBGM(gameOverBGM, true, 1.0f);
|
||||
currentBGMTrack = "GameOver";
|
||||
}
|
||||
}
|
||||
|
||||
// 승리 시 호출
|
||||
public void PlayVictoryMusic()
|
||||
{
|
||||
if (SoundManager.Instance == null) return;
|
||||
|
||||
if (victoryBGM != null)
|
||||
{
|
||||
SoundManager.Instance.PlayBGM(victoryBGM, true, 1.0f);
|
||||
currentBGMTrack = "Victory";
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 효과음 제어
|
||||
|
||||
// 버튼 클릭 효과음 재생
|
||||
public void PlayButtonClickSound()
|
||||
{
|
||||
if (SoundManager.Instance == null) return;
|
||||
|
||||
SoundManager.Instance.PlaySFX("ButtonClick");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 몬스터 오디오
|
||||
|
||||
public void PlayMonsterAttackSound()
|
||||
{
|
||||
if (SoundManager.Instance == null) return;
|
||||
|
||||
SoundManager.Instance.PlaySFX("MonsterAttack");
|
||||
}
|
||||
|
||||
public void PlayMonsterDeathSound()
|
||||
{
|
||||
if (SoundManager.Instance == null) return;
|
||||
|
||||
SoundManager.Instance.PlaySFX("MonsterDeath");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae7f2b39529d58a4fa75cf1d30dae9be
|
||||
guid: f076e9ce37f6f564c961ee8a9393c09d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
272
Assets/Scripts/Common/SoundManager.cs
Normal file
272
Assets/Scripts/Common/SoundManager.cs
Normal file
@ -0,0 +1,272 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
// SoundManager: 효과음 및 배경음 재생, 정지, 볼륨 조절, 페이드 효과 등을 관리
|
||||
public class SoundManager : Singleton<SoundManager>
|
||||
{
|
||||
// 오디오 소스 관리
|
||||
private AudioSource bgmSource;
|
||||
private List<AudioSource> sfxSources = new List<AudioSource>();
|
||||
|
||||
// 볼륨 설정 (0.0 ~ 1.0)
|
||||
[Range(0f, 1f)] public float bgmVolume = 1f;
|
||||
[Range(0f, 1f)] public float sfxVolume = 1f;
|
||||
|
||||
// 오디오 클립 저장소
|
||||
private Dictionary<string, AudioClip> audioClips = new Dictionary<string, AudioClip>();
|
||||
|
||||
// 동시에 재생 가능한 효과음 수
|
||||
private int maxSfxSources = 5;
|
||||
|
||||
// 페이드 효과 진행 여부
|
||||
private bool isFading = false;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
InitializeAudioSources();
|
||||
}
|
||||
|
||||
private void InitializeAudioSources()
|
||||
{
|
||||
// 배경음 오디오 소스가 없으면 생성
|
||||
if (bgmSource == null)
|
||||
{
|
||||
bgmSource = gameObject.AddComponent<AudioSource>();
|
||||
bgmSource.loop = true;
|
||||
bgmSource.volume = bgmVolume;
|
||||
}
|
||||
|
||||
// 효과음 오디오 소스가 부족하면 추가 생성
|
||||
for (int i = 0; i < maxSfxSources; i++)
|
||||
{
|
||||
AudioSource sfxSource = gameObject.AddComponent<AudioSource>();
|
||||
sfxSource.loop = false;
|
||||
sfxSource.volume = sfxVolume;
|
||||
sfxSources.Add(sfxSource);
|
||||
}
|
||||
}
|
||||
|
||||
// 싱글톤 클래스의 추상 메서드 구현
|
||||
protected override void OnSceneLoaded(Scene scene, LoadSceneMode mode)
|
||||
{
|
||||
// 씬 전환 시 음악 전체 정지 (효과음, 배경음 모두)
|
||||
// StopAllSounds();
|
||||
}
|
||||
|
||||
#region 오디오 클립 관리
|
||||
|
||||
// 오디오 클립을 audioClips에 저장 (식별을 위한 이름 포함)
|
||||
public void LoadAudioClip(string name, AudioClip clip)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name) || clip == null) return;
|
||||
|
||||
if (!audioClips.ContainsKey(name))
|
||||
{
|
||||
audioClips.Add(name, clip);
|
||||
}
|
||||
else
|
||||
{
|
||||
audioClips[name] = clip;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 배경음 (BGM) 메서드
|
||||
|
||||
// 이름으로 배경음을 재생
|
||||
public void PlayBGM(string clipName, bool fade = false, float fadeTime = 1f)
|
||||
{
|
||||
if (string.IsNullOrEmpty(clipName) || !audioClips.ContainsKey(clipName)) return;
|
||||
|
||||
PlayBGM(audioClips[clipName], fade, fadeTime);
|
||||
}
|
||||
|
||||
// 오디오 클립으로 배경음을 재생
|
||||
public void PlayBGM(AudioClip clip, bool fade = false, float fadeTime = 1f)
|
||||
{
|
||||
if (clip == null) return;
|
||||
|
||||
if (bgmSource == null) InitializeAudioSources(); // 초기화 안됐을 경우 다시 초기화
|
||||
|
||||
// 같은 클립이 이미 재생 중이면 중복 재생하지 않음
|
||||
if (bgmSource.clip == clip && bgmSource.isPlaying)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (fade && !isFading)
|
||||
{
|
||||
StartCoroutine(FadeBGM(clip, fadeTime));
|
||||
}
|
||||
else
|
||||
{
|
||||
bgmSource.clip = clip;
|
||||
bgmSource.volume = bgmVolume;
|
||||
bgmSource.Play();
|
||||
}
|
||||
}
|
||||
|
||||
// 배경음을 정지
|
||||
public void StopBGM(bool fade = false, float fadeTime = 1f)
|
||||
{
|
||||
if (bgmSource == null || !bgmSource.isPlaying) return;
|
||||
|
||||
if (fade && !isFading)
|
||||
{
|
||||
StartCoroutine(FadeOutBGM(fadeTime));
|
||||
}
|
||||
else
|
||||
{
|
||||
bgmSource.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
// 배경음 볼륨을 설정
|
||||
public void SetBGMVolume(float volume)
|
||||
{
|
||||
bgmVolume = Mathf.Clamp01(volume);
|
||||
if (bgmSource == null) InitializeAudioSources();
|
||||
|
||||
bgmSource.volume = bgmVolume;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 효과음 (SFX) 메서드
|
||||
|
||||
// 이름으로 효과음을 재생
|
||||
public AudioSource PlaySFX(string clipName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(clipName) || !audioClips.ContainsKey(clipName)) return null;
|
||||
|
||||
return PlaySFX(audioClips[clipName]);
|
||||
}
|
||||
|
||||
// 오디오 클립으로 효과음을 재생
|
||||
public AudioSource PlaySFX(AudioClip clip)
|
||||
{
|
||||
if (clip == null) return null;
|
||||
|
||||
if (sfxSources == null || sfxSources.Count == 0) InitializeAudioSources(); // 초기화
|
||||
|
||||
// 사용 가능한 효과음 소스 찾기
|
||||
AudioSource sfxSource = null;
|
||||
foreach (var source in sfxSources)
|
||||
{
|
||||
if (!source.isPlaying)
|
||||
{
|
||||
sfxSource = source;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 모든 소스가 사용 중이면 첫 번째 소스 재사용
|
||||
if (sfxSource == null && sfxSources.Count > 0)
|
||||
{
|
||||
sfxSource = sfxSources[0];
|
||||
}
|
||||
|
||||
sfxSource.clip = clip;
|
||||
sfxSource.volume = sfxVolume;
|
||||
sfxSource.Play();
|
||||
|
||||
return sfxSource;
|
||||
}
|
||||
|
||||
// 모든 효과음을 정지
|
||||
public void StopAllSFX()
|
||||
{
|
||||
foreach (var source in sfxSources)
|
||||
{
|
||||
source.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
// 효과음 볼륨을 설정
|
||||
public void SetSFXVolume(float volume)
|
||||
{
|
||||
sfxVolume = Mathf.Clamp01(volume);
|
||||
foreach (var source in sfxSources)
|
||||
{
|
||||
source.volume = sfxVolume;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 전체 사운드 제어
|
||||
|
||||
/// 모든 사운드(배경음, 효과음)를 정지
|
||||
public void StopAllSounds()
|
||||
{
|
||||
StopBGM();
|
||||
StopAllSFX();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 페이드 효과
|
||||
|
||||
// 배경음을 페이드 인/아웃하며 전환
|
||||
private IEnumerator FadeBGM(AudioClip newClip, float fadeTime)
|
||||
{
|
||||
isFading = true;
|
||||
|
||||
// 현재 재생 중인 배경음이 있으면 페이드 아웃
|
||||
if (bgmSource.isPlaying)
|
||||
{
|
||||
float startVolume = bgmSource.volume;
|
||||
float time = 0;
|
||||
|
||||
while (time < fadeTime / 2)
|
||||
{
|
||||
bgmSource.volume = Mathf.Lerp(startVolume, 0, time / (fadeTime / 2));
|
||||
time += Time.deltaTime;
|
||||
yield return null;
|
||||
}
|
||||
|
||||
bgmSource.Stop();
|
||||
}
|
||||
|
||||
// 새 클립 설정 후 페이드 인
|
||||
bgmSource.clip = newClip;
|
||||
bgmSource.volume = 0;
|
||||
bgmSource.Play();
|
||||
|
||||
float fadeInTime = 0;
|
||||
while (fadeInTime < fadeTime / 2)
|
||||
{
|
||||
bgmSource.volume = Mathf.Lerp(0, bgmVolume, fadeInTime / (fadeTime / 2));
|
||||
fadeInTime += Time.deltaTime;
|
||||
yield return null;
|
||||
}
|
||||
|
||||
bgmSource.volume = bgmVolume;
|
||||
isFading = false;
|
||||
}
|
||||
|
||||
// 배경음을 페이드 아웃
|
||||
private IEnumerator FadeOutBGM(float fadeTime)
|
||||
{
|
||||
isFading = true;
|
||||
|
||||
float startVolume = bgmSource.volume;
|
||||
float time = 0;
|
||||
|
||||
while (time < fadeTime)
|
||||
{
|
||||
bgmSource.volume = Mathf.Lerp(startVolume, 0, time / fadeTime);
|
||||
time += Time.deltaTime;
|
||||
yield return null;
|
||||
}
|
||||
|
||||
bgmSource.Stop();
|
||||
bgmSource.volume = bgmVolume;
|
||||
isFading = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb5079b7064e2324890f78e18dfe7a6e
|
||||
guid: 9b22d6af280f6ed4aa3a6dbeed301cd6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
Loading…
x
Reference in New Issue
Block a user