설정수정

This commit is contained in:
2026-06-26 13:18:33 +09:00
parent 29f21a130e
commit c0574abb80
9 changed files with 97 additions and 7 deletions

View File

@@ -34,6 +34,42 @@ public void SetZone(Zone zone)
public void OnSceneLoaded()
{
ResolveZoneAtSpawn();
}
//씬 로드 직후, 플레이어가 서 있는 위치에서 ZoneTrigger를 직접 조회해 구역을 확정한다.
//None을 깔고 OnTriggerEnter를 기다리는 방식의 BGM 글리치/누락(스폰 즉시 트리거 안인 경우)을 피하기 위함.
private void ResolveZoneAtSpawn()
{
Zone resolved = Zone.None;
var player = GameObject.FindGameObjectWithTag("Player");
if (player != null)
{
//콜라이더는 Awake/OnEnable에서 이미 물리씬에 등록되므로 첫 물리 스텝 전에도 즉시 조회 가능
Collider[] hits = Physics.OverlapSphere(
player.transform.position, 0.1f, ~0, QueryTriggerInteraction.Collide);
foreach (var hit in hits)
{
if (hit.TryGetComponent<ZoneTrigger>(out var trigger))
{
resolved = trigger.Zone;
break;
}
}
}
SetZone(resolved); //이전 구역과 같으면 dedup되어 BGM이 끊김 없이 이어진다
}
//게임 종료 (에디터에서는 플레이 모드 중지, 빌드에서는 앱 종료)
public void QuitGame()
{
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#else
Application.Quit();
#endif
}
}

View File

@@ -149,6 +149,18 @@ private async Awaitable SightFadeAsync(float targetAlpha, CancellationToken toke
catch (OperationCanceledException) { }
}
// GameManager를 통해 게임을 종료한다. (UI 버튼·타임라인 시그널 등에서 호출)
public void QuitGame()
{
if (GameManager.Instance == null)
{
Debug.LogWarning("[PlayerController] GameManager.Instance가 없습니다. 게임을 종료할 수 없습니다.");
return;
}
GameManager.Instance.QuitGame();
}
private void Update()
{
// 바닥 체크 및 Y축 속도 초기화

View File

@@ -7,6 +7,9 @@ public class ZoneTrigger : MonoBehaviour
[SerializeField] private Zone _zone; //이 영역이 나타내는 구역
[SerializeField] private string _playerTag = "Player"; //플레이어로 인식할 태그
//스폰 위치 판정 등에서 외부가 이 트리거의 구역을 읽을 수 있도록 노출
public Zone Zone => _zone;
private void Reset()
{
//이 컴포넌트를 붙이면 콜라이더를 자동으로 트리거로 설정