From e98b6f610dea2565fada1c75a8161ff847129c49 Mon Sep 17 00:00:00 2001 From: nakjun Date: Wed, 15 Jul 2026 14:07:25 +0900 Subject: [PATCH] =?UTF-8?q?=EB=8C=80=ED=99=94=EC=8B=9C=EC=8A=A4=ED=85=9C?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/01_Scenes/Hischool_Chapter1.unity | 4 +-- Assets/01_Scenes/Hischool_Chapter2.unity | 4 +-- Assets/02_Scripts/Managers/StoryManager.cs | 4 +++ .../02_Scripts/UI/Communication/DialogHud.cs | 33 +++++++++++++++++-- .../XR/Settings/OpenXR Package Settings.asset | 4 +-- 5 files changed, 41 insertions(+), 8 deletions(-) diff --git a/Assets/01_Scenes/Hischool_Chapter1.unity b/Assets/01_Scenes/Hischool_Chapter1.unity index 1ce4ae98..83991691 100644 --- a/Assets/01_Scenes/Hischool_Chapter1.unity +++ b/Assets/01_Scenes/Hischool_Chapter1.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6b45c9b4262eba992b7320325dbd2a0151180dd533ee6dcc0d8853e1ad7b504c -size 4202174 +oid sha256:ac85fe95ab871012f016779e60257f31985d0e27be0a1f74fec4342d6f9f99ab +size 4204337 diff --git a/Assets/01_Scenes/Hischool_Chapter2.unity b/Assets/01_Scenes/Hischool_Chapter2.unity index c8aad034..2b5d260b 100644 --- a/Assets/01_Scenes/Hischool_Chapter2.unity +++ b/Assets/01_Scenes/Hischool_Chapter2.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a8c6070a71d72f616d6ff01f90a72115226474e19600cdd4be48df0485dd3504 -size 4043377 +oid sha256:ef5051b0c9dc8c9b61a60bd5088d6f166f67ef28847e582909d673cb793cd146 +size 4044502 diff --git a/Assets/02_Scripts/Managers/StoryManager.cs b/Assets/02_Scripts/Managers/StoryManager.cs index 1bc4bb56..c2a0cc86 100644 --- a/Assets/02_Scripts/Managers/StoryManager.cs +++ b/Assets/02_Scripts/Managers/StoryManager.cs @@ -38,6 +38,10 @@ public int MainProgress } } + // UnityEvent 연결용 (버튼·이벤트존·노드 이벤트 등에서 진행도 조작) + public void AddMainProgress(int amount) => MainProgress += amount; + public void SetMainProgress(int value) => MainProgress = value; + // ── 호감도 ────────────────────────────────────────────────── public int GetAffection(CharacterData character) => character != null && _state.Affection.TryGetValue(IdOf(character), out var v) ? v : 0; diff --git a/Assets/02_Scripts/UI/Communication/DialogHud.cs b/Assets/02_Scripts/UI/Communication/DialogHud.cs index 2580c726..4b5a56ff 100644 --- a/Assets/02_Scripts/UI/Communication/DialogHud.cs +++ b/Assets/02_Scripts/UI/Communication/DialogHud.cs @@ -48,6 +48,9 @@ public struct PlacementCandidate [Tooltip("충돌 검사에 쓰는 대사창 절반 크기 — 실제 캔버스 크기에 맞출 것")] [SerializeField] private Vector3 _panelHalfExtents = new(0.5f, 0.3f, 0.05f); + [Tooltip("가림 허용 비율 — 패널 표본점(5×4=20점, 1점=5%) 중 이 비율까지는 가려져도 통과")] + [Range(0f, 1f)] [SerializeField] private float _maxOccludedFraction = 0.05f; + private Transform _speakerTransform; private float _activeChestHeight; private float _activeForwardOffset; @@ -149,8 +152,8 @@ private void ApplyBestCandidate(List candidates) // 벽/지형에 겹치는가 if (Physics.CheckBox(pos, _panelHalfExtents, rot, _obstacleMask, QueryTriggerInteraction.Ignore)) continue; - // 플레이어 눈에서 벽에 가려지는가 - if (Physics.Linecast(camPos, pos, _obstacleMask, QueryTriggerInteraction.Ignore)) + // 플레이어 눈에서 벽에 가려지는가 — 패널 전체를 표본점으로 검사해 허용 비율까지만 통과 + if (OccludedFraction(camPos, pos, rot) > _maxOccludedFraction) continue; ApplyCandidate(cand); @@ -159,6 +162,32 @@ private void ApplyBestCandidate(List candidates) // 전부 실패 — 미리 적용해 둔 첫 후보(기본) 그대로 사용 } + // 카메라 눈에서 패널 표면 표본점들로 레이를 쏴서 벽에 가려진 비율(0~1)을 구한다. + // 표본은 패널 사각형을 모서리·가장자리까지 덮는 5×4 격자 — 중심 한 점만 검사하면 + // 가장자리가 벽 뒤로 반쯤 걸쳐도 통과해 버리는 문제를 잡기 위한 것. + private const int _occlusionCols = 5; + private const int _occlusionRows = 4; + + private float OccludedFraction(Vector3 camPos, Vector3 center, Quaternion rot) + { + Vector3 right = rot * Vector3.right * _panelHalfExtents.x; + Vector3 up = rot * Vector3.up * _panelHalfExtents.y; + + int blocked = 0; + for (int r = 0; r < _occlusionRows; r++) + { + float v = (float)r / (_occlusionRows - 1) * 2f - 1f; // -1(아래) ~ +1(위) + for (int c = 0; c < _occlusionCols; c++) + { + float u = (float)c / (_occlusionCols - 1) * 2f - 1f; // -1(좌) ~ +1(우) + Vector3 p = center + right * u + up * v; + if (Physics.Linecast(camPos, p, _obstacleMask, QueryTriggerInteraction.Ignore)) + blocked++; + } + } + return (float)blocked / (_occlusionRows * _occlusionCols); + } + private void LateUpdate() { if (_speakerTransform == null) return; diff --git a/Assets/XR/Settings/OpenXR Package Settings.asset b/Assets/XR/Settings/OpenXR Package Settings.asset index 491975a3..62b5f4f4 100644 --- a/Assets/XR/Settings/OpenXR Package Settings.asset +++ b/Assets/XR/Settings/OpenXR Package Settings.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:714222d27184d5c447c8b15c074db9fd77257e013178bfc1c6ce2532e3caf92e -size 136206 +oid sha256:bf1dc8e6c38ff971bf80a6b1ca599a70b1d7816eebffd1b1792a9e2d719b7f4d +size 136208