2026-06-18 앉기 UI등등

This commit is contained in:
2026-06-18 18:09:08 +09:00
parent 83b3c4a27c
commit f69d0ef273
173 changed files with 359 additions and 6 deletions

View File

@@ -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;
}
}

View File

@@ -9,6 +9,8 @@ public abstract class InteractionObject : MonoBehaviour
[SerializeField] protected Transform _interactionPos;
[SerializeField] protected GameObject _visible;
// 지속형 상호작용이 진행 중인지 (예: 앉아있는 중).
// true인 동안 디텍터는 대상을 이 오브젝트로 잠가, 다음 키 입력이 종료(해제)로 가게 한다.
public bool IsInteracting { get; protected set; }
@@ -17,4 +19,9 @@ public abstract class InteractionObject : MonoBehaviour
// 상호작용 키를 눌렀을 때 호출. 시작/종료(토글) 여부는 각 구현이 결정한다.
public abstract void Interact(PlayerController player);
public void VisibleUI(bool isOn)
{
_visible.SetActive(isOn);
}
}