From 3d882fcc8cedc910b9117a4b4782eedd3c21ca32 Mon Sep 17 00:00:00 2001 From: nakjun Date: Fri, 19 Jun 2026 17:58:22 +0900 Subject: [PATCH] =?UTF-8?q?2026-06-19=20=EC=9B=94=EB=93=9C=EB=8B=A4?= =?UTF-8?q?=EC=9D=B4=EC=96=BC=EB=A1=9C=EA=B7=B8=20=ED=94=84=EB=A1=9C?= =?UTF-8?q?=ED=86=A0=ED=83=80=EC=9E=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dialog/CatsRoomDialogTest.unity | 4 +- .../Communication/Dialog/DialogPlayer.cs | 10 ++++- Assets/02_Scripts/UI/DialogHud.cs | 24 +++++++++-- Assets/04_Models/UI/Dialog/ChoiceRow.prefab | 4 +- .../DialogGraph/DialogGraph_Test.wdg | 41 +++++++++++++++++++ .../Fonts/Pretendard-Black SDF.asset | 4 +- 6 files changed, 76 insertions(+), 11 deletions(-) diff --git a/Assets/01_Scenes/WhaleAdventure_VR/Dialog/CatsRoomDialogTest.unity b/Assets/01_Scenes/WhaleAdventure_VR/Dialog/CatsRoomDialogTest.unity index 0b35ce51..aa6b1c74 100644 --- a/Assets/01_Scenes/WhaleAdventure_VR/Dialog/CatsRoomDialogTest.unity +++ b/Assets/01_Scenes/WhaleAdventure_VR/Dialog/CatsRoomDialogTest.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8f9c0e9b01a5cbfc2c9502388cf3b480825003206872dc0e799099552dcf429b -size 2122975 +oid sha256:bde2dfa766c80dbc6a4bf56cfa210130c684102e0d8b9d01392b440e469b696b +size 2123570 diff --git a/Assets/02_Scripts/Communication/Dialog/DialogPlayer.cs b/Assets/02_Scripts/Communication/Dialog/DialogPlayer.cs index f4c9a391..340a01bf 100644 --- a/Assets/02_Scripts/Communication/Dialog/DialogPlayer.cs +++ b/Assets/02_Scripts/Communication/Dialog/DialogPlayer.cs @@ -6,6 +6,12 @@ public class DialogPlayer : MonoBehaviour { [SerializeField] private List _dialogGroups; + + [Header("Dialog HUD Placement")] // 씬에서 캐릭터 위치/주변(벽 등)에 맞춰 조절 + [SerializeField] private float _hudChestHeight = 1.2f; // 화자 발 기준 가슴 높이 + [SerializeField] private float _hudForwardOffset = 0.5f; // 화자→플레이어 방향으로 띄울 거리 + [SerializeField] private float _hudLateralOffset = 0f; // 좌우 오프셋 (+ 플레이어 시점 오른쪽) + private Dictionary _dialogGroupMap; private Animator _animator; private int _initialGestureHash; @@ -134,9 +140,9 @@ private async Awaitable RotateToRotation(Transform target, Quaternion targetRota private async Awaitable PlayNode(DialogNode node) { - // 화자 옆 DialogHud에 대사 표시 + // 화자 옆 DialogHud에 대사 표시 (배치 오프셋은 이 NPC의 설정값 사용) if (DialogHud.Instance != null) - DialogHud.Instance.Show(node.Speaker, node.TalkText); + DialogHud.Instance.Show(node.Speaker, node.TalkText, _hudChestHeight, _hudForwardOffset, _hudLateralOffset); // 보이스 재생 if (node.Voice != null && node.Speaker != null) diff --git a/Assets/02_Scripts/UI/DialogHud.cs b/Assets/02_Scripts/UI/DialogHud.cs index 71ce2576..98ac38fd 100644 --- a/Assets/02_Scripts/UI/DialogHud.cs +++ b/Assets/02_Scripts/UI/DialogHud.cs @@ -17,11 +17,16 @@ public class DialogHud : MonoBehaviour [SerializeField] private TMP_Text _speakerName; [SerializeField] private TMP_Text _dialogueText; - [Header("Placement")] + [Header("Placement (기본값 — Show에서 오프셋을 안 넘길 때 폴백)")] [SerializeField] private float _chestHeight = 1.2f; // 화자 발 기준 가슴 높이 [SerializeField] private float _forwardOffset = 0.5f; // 화자→플레이어 방향으로 띄울 거리 + [SerializeField] private float _lateralOffset = 0f; // 좌우 오프셋 (+ 플레이어 시점 오른쪽) private Transform _speakerTransform; + private float _activeChestHeight; + private float _activeForwardOffset; + private float _activeLateralOffset; + private bool _placed; // 처음 한 번만 배치하고 이후엔 고정 private void Awake() { @@ -35,9 +40,17 @@ private void OnDestroy() if (Instance == this) Instance = null; } + // DialogHud 자체 기본 오프셋 사용 public void Show(CharacterData speaker, string text) + => Show(speaker, text, _chestHeight, _forwardOffset, _lateralOffset); + + // 배치 오프셋을 직접 넘겨 사용 (DialogPlayer가 NPC/씬별 값 전달) + public void Show(CharacterData speaker, string text, float chestHeight, float forwardOffset, float lateralOffset) { _speakerTransform = speaker != null ? CharacterVoiceObject.Find(speaker)?.transform : null; + _activeChestHeight = chestHeight; + _activeForwardOffset = forwardOffset; + _activeLateralOffset = lateralOffset; if (_speakerName != null) _speakerName.text = speaker != null ? speaker.Name : string.Empty; @@ -53,10 +66,12 @@ public void Hide() if (_speakerName != null) _speakerName.text = string.Empty; if (_panel != null) _panel.SetActive(false); _speakerTransform = null; + _placed = false; // 다음에 다시 뜰 때 재배치 } private void LateUpdate() { + if (_placed) return; // 처음 위치에 고정 — 이후 플레이어가 움직여도 안 따라감 if (_speakerTransform == null || Camera.main == null) return; var camTr = Camera.main.transform; @@ -67,10 +82,13 @@ private void LateUpdate() if (toCam.sqrMagnitude < 0.0001f) return; Vector3 dir = toCam.normalized; - Vector3 chestWorld = _speakerTransform.position + Vector3.up * _chestHeight; - transform.position = chestWorld + dir * _forwardOffset; + Vector3 right = Vector3.Cross(dir, Vector3.up); // 플레이어 시점 기준 오른쪽(수평) + Vector3 chestWorld = _speakerTransform.position + Vector3.up * _activeChestHeight; + transform.position = chestWorld + dir * _activeForwardOffset + right * _activeLateralOffset; // 빌보드 — 캔버스의 -Z(읽는 면)가 카메라를 향하도록 +Z를 카메라 반대로 transform.rotation = Quaternion.LookRotation(-dir); + + _placed = true; // 한 번 배치 후 고정 } } diff --git a/Assets/04_Models/UI/Dialog/ChoiceRow.prefab b/Assets/04_Models/UI/Dialog/ChoiceRow.prefab index 68e35102..bc2ab6e1 100644 --- a/Assets/04_Models/UI/Dialog/ChoiceRow.prefab +++ b/Assets/04_Models/UI/Dialog/ChoiceRow.prefab @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:970f0e0b82e8a90ae14fb69b743adab27f4d6acd5b38499eef88b06cbbc952cb -size 6090 +oid sha256:1a8bd0da907b7401c72d6fd1a34a44cd1a3c6feb4b774c33af43247d3f0da434 +size 8340 diff --git a/Assets/07_Data/Communication/DialogGraph/DialogGraph_Test.wdg b/Assets/07_Data/Communication/DialogGraph/DialogGraph_Test.wdg index c0adc399..03c53889 100644 --- a/Assets/07_Data/Communication/DialogGraph/DialogGraph_Test.wdg +++ b/Assets/07_Data/Communication/DialogGraph/DialogGraph_Test.wdg @@ -43,6 +43,7 @@ MonoBehaviour: - rid: 6595524284503556412 - rid: 6595524284503556423 - rid: 6595524284503556434 + - rid: 6595524284503556444 m_GraphStickyNoteModels: [] m_GraphPlacematModels: [] m_GraphVariableModels: [] @@ -153,6 +154,14 @@ MonoBehaviour: Hash: 68f89b4619f130d76186d50b78a7609a m_Category: 2 m_Index: 4 + - m_Guid: + m_Value0: 3380853770992205313 + m_Value1: 18053617693641326980 + m_HashGuid: + serializedVersion: 2 + Hash: 01be87999734eb2e84c132e4a3558bfa + m_Category: 2 + m_Index: 5 m_EntryPoint: rid: 6595524284503556358 m_Graph: @@ -908,3 +917,35 @@ MonoBehaviour: - rid: 6595524284503556443 type: {class: DialogLineNode, ns: WhaleAdventure.Dialog.GraphTool.Editor, asm: Assembly-CSharp-Editor} data: + - rid: 6595524284503556444 + type: {class: WireModel, ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Guid: + m_Value0: 3380853770992205313 + m_Value1: 18053617693641326980 + m_HashGuid: + serializedVersion: 2 + Hash: 01be87999734eb2e84c132e4a3558bfa + m_Version: 2 + m_FromPortReference: + m_NodeModelGuid: + m_Value0: 13710833896111860515 + m_Value1: 8096942652718749771 + m_NodeModelHashGuid: + serializedVersion: 2 + Hash: 23eb2110c9aa46be4b980276711e5e70 + m_UniqueId: Out + m_PortDirection: 2 + m_PortOrientation: 0 + m_Title: + m_ToPortReference: + m_NodeModelGuid: + m_Value0: 15671640390660357946 + m_Value1: 11221916553219458534 + m_NodeModelHashGuid: + serializedVersion: 2 + Hash: 3a7ff944e7d97cd9e6c5b81da641bc9b + m_UniqueId: In + m_PortDirection: 1 + m_PortOrientation: 0 + m_Title: diff --git a/Assets/My project/Fonts/Pretendard-Black SDF.asset b/Assets/My project/Fonts/Pretendard-Black SDF.asset index 97066da3..293ca15c 100644 --- a/Assets/My project/Fonts/Pretendard-Black SDF.asset +++ b/Assets/My project/Fonts/Pretendard-Black SDF.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b8d51216abd7819fa6e67636c4783e3a988b9048d14dd43ad6591cbcc5f7962e -size 41436112 +oid sha256:33d1b8ab213c79b046892d59ef6d55391add80541b88fe972cee7a9f0b27f0ac +size 41448806