2026-06-18 앉기 UI등등
This commit is contained in:
@@ -16,6 +16,7 @@ public class InteractionDetector : MonoBehaviour, ISceneInitializable
|
||||
|
||||
private InteractionObject _current; // 가장 가까운 상호작용 대상 (없으면 null)
|
||||
private InteractionObject _active; // 진행 중인 지속형 상호작용 (앉아있는 의자 등). 있으면 대상 잠금
|
||||
private InteractionObject _uiShown; // 현재 UI가 켜져 있는 대상 (_current는 이벤트 전에 갱신돼 비교 불가 → 별도 추적)
|
||||
private readonly Collider[] _hits = new Collider[16]; // OverlapSphereNonAlloc 결과 버퍼
|
||||
|
||||
// UI 프롬프트용: 상호작용 가능한 대상이 바뀔 때 호출 (null이면 "대상 없음")
|
||||
@@ -44,12 +45,18 @@ private void Subscribe()
|
||||
}
|
||||
InputManager.Instance.OnInteract_Event -= HandleInteract;
|
||||
InputManager.Instance.OnInteract_Event += HandleInteract;
|
||||
|
||||
|
||||
OnInteractableChanged -= InteractionUIVisible;
|
||||
OnInteractableChanged += InteractionUIVisible;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
if (InputManager.Instance != null)
|
||||
InputManager.Instance.OnInteract_Event -= HandleInteract;
|
||||
|
||||
OnInteractableChanged -= InteractionUIVisible;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
@@ -129,4 +136,17 @@ private void OnDrawGizmosSelected()
|
||||
Gizmos.color = Color.cyan;
|
||||
Gizmos.DrawWireSphere(transform.position, _detectRadius);
|
||||
}
|
||||
|
||||
public void InteractionUIVisible(InteractionObject io)
|
||||
{
|
||||
if (io == _uiShown) return; // 이미 그 대상 UI가 켜져 있으면 무시
|
||||
|
||||
if (_uiShown != null)
|
||||
_uiShown.VisibleUI(false); // 이전 대상 UI 끄기
|
||||
|
||||
if (io != null)
|
||||
io.VisibleUI(true); // 새 대상 UI 켜기
|
||||
|
||||
_uiShown = io;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user