From 752b891a481a6179c1b4a04d9cd335cb3d0d1665 Mon Sep 17 00:00:00 2001 From: "DESKTOP-VVOCIJO\\PC" Date: Fri, 24 Apr 2026 17:46:29 +0900 Subject: [PATCH] =?UTF-8?q?2026-04-24=20=EC=BA=90=EB=A6=AD=ED=84=B0=20?= =?UTF-8?q?=EC=83=81=ED=98=B8=EC=9E=91=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/01_Scenes/MyProject/GameScene.unity | 4 +- .../Communication/Dialog/DialogPlayer.cs | 39 ++++++++++++------- .../02_Scripts/Interact/DialogInteractable.cs | 19 +++++++++ .../Interact/DialogInteractable.cs.meta | 2 + .../03_Models/_Characters/Black/Black.prefab | 4 +- ProjectSettings/TagManager.asset | 4 +- 6 files changed, 51 insertions(+), 21 deletions(-) create mode 100644 Assets/02_Scripts/Interact/DialogInteractable.cs create mode 100644 Assets/02_Scripts/Interact/DialogInteractable.cs.meta diff --git a/Assets/01_Scenes/MyProject/GameScene.unity b/Assets/01_Scenes/MyProject/GameScene.unity index 016b4c1d..a7e14145 100644 --- a/Assets/01_Scenes/MyProject/GameScene.unity +++ b/Assets/01_Scenes/MyProject/GameScene.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cd9cf3a0f140d5658c4f3d1ff7f8d4b2e9659aae13386bc9b232d4378b0dd816 -size 13300705 +oid sha256:6c89de8523eb4771ff23d9e9f33f8e9eabb669709057cb779faae2162c7099ee +size 13298628 diff --git a/Assets/02_Scripts/Communication/Dialog/DialogPlayer.cs b/Assets/02_Scripts/Communication/Dialog/DialogPlayer.cs index 73b01ca2..75633220 100644 --- a/Assets/02_Scripts/Communication/Dialog/DialogPlayer.cs +++ b/Assets/02_Scripts/Communication/Dialog/DialogPlayer.cs @@ -8,6 +8,7 @@ public class DialogPlayer : MonoBehaviour [SerializeField] private List _dialogGroups; private Dictionary _dialogGroupMap; private Animator _animator; + public bool IsPlaying { get; private set; } private void Awake() { @@ -18,36 +19,44 @@ private void Awake() _animator = GetComponentInChildren(); } - // 임시 테스트용 - private void Update() + public async Awaitable Play() { - if (Keyboard.current != null && Keyboard.current.tKey.wasPressedThisFrame) - _ = Play("BlackDialogGroup1"); + if(_dialogGroups.Count > 0) + _ = Play(_dialogGroups[0].DialogGroupName); } public async Awaitable Play(string groupName) { + if (IsPlaying) return; if (!_dialogGroupMap.TryGetValue(groupName, out var group)) { Debug.LogWarning($"[DialogPlayer] 그룹 없음: {groupName}"); return; } - var node = group.StartNode; - while (node != null) + IsPlaying = true; + try { - await PlayNode(node); + var node = group.StartNode; + while (node != null) + { + await PlayNode(node); - if (node.Choices != null && node.Choices.Count > 0) - { - int picked = await WaitForChoice(node); - node = node.Choices[picked].DestinationNode; - } - else - { - node = node.Next; + if (node.Choices != null && node.Choices.Count > 0) + { + int picked = await WaitForChoice(node); + node = node.Choices[picked].DestinationNode; + } + else + { + node = node.Next; + } } } + finally + { + IsPlaying = false; + } Debug.Log("[DialogPlayer] 대화 종료"); } diff --git a/Assets/02_Scripts/Interact/DialogInteractable.cs b/Assets/02_Scripts/Interact/DialogInteractable.cs new file mode 100644 index 00000000..f426f5ae --- /dev/null +++ b/Assets/02_Scripts/Interact/DialogInteractable.cs @@ -0,0 +1,19 @@ +using UnityEngine; +using UnityEngine.XR.Interaction.Toolkit; + +[RequireComponent(typeof(DialogPlayer))] +public class DialogInteractable : MonoBehaviour +{ + private DialogPlayer _player; + + private void Awake() + { + _player = GetComponent(); + } + + public void HandleActivated(ActivateEventArgs args) + { + if (_player == null || _player.IsPlaying) return; + _ = _player.Play(); + } +} \ No newline at end of file diff --git a/Assets/02_Scripts/Interact/DialogInteractable.cs.meta b/Assets/02_Scripts/Interact/DialogInteractable.cs.meta new file mode 100644 index 00000000..344cbcd4 --- /dev/null +++ b/Assets/02_Scripts/Interact/DialogInteractable.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: a8a22189f0d1e5448bf3e44657410176 \ No newline at end of file diff --git a/Assets/03_Models/_Characters/Black/Black.prefab b/Assets/03_Models/_Characters/Black/Black.prefab index ed5894a6..7ea71c44 100644 --- a/Assets/03_Models/_Characters/Black/Black.prefab +++ b/Assets/03_Models/_Characters/Black/Black.prefab @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:36d4feaaf36410566bf23b8c1037133596a12edfcb7afebbcfa4ea59f7067f9a -size 164992 +oid sha256:5569e27023bc0fe6983ac3842ce2fab3b091e24b877c7257adc18702bda94d8d +size 172712 diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index 9bc8dc67..be3e6a6b 100644 --- a/ProjectSettings/TagManager.asset +++ b/ProjectSettings/TagManager.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3ebaf9ae5fe64f49dd01cd51fd31043a0082dec91cfb6e7e578d37d9a427b24f -size 583 +oid sha256:ce07a0e5231e8d624e8abe4a275c052f3a71cc53d327e0f03fce82e777b37828 +size 601