2026-04-24 캐릭터 상호작용
This commit is contained in:
Binary file not shown.
@@ -8,6 +8,7 @@ public class DialogPlayer : MonoBehaviour
|
|||||||
[SerializeField] private List<DialogGroup> _dialogGroups;
|
[SerializeField] private List<DialogGroup> _dialogGroups;
|
||||||
private Dictionary<string, DialogGroup> _dialogGroupMap;
|
private Dictionary<string, DialogGroup> _dialogGroupMap;
|
||||||
private Animator _animator;
|
private Animator _animator;
|
||||||
|
public bool IsPlaying { get; private set; }
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
@@ -18,36 +19,44 @@ private void Awake()
|
|||||||
_animator = GetComponentInChildren<Animator>();
|
_animator = GetComponentInChildren<Animator>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 임시 테스트용
|
public async Awaitable Play()
|
||||||
private void Update()
|
|
||||||
{
|
{
|
||||||
if (Keyboard.current != null && Keyboard.current.tKey.wasPressedThisFrame)
|
if(_dialogGroups.Count > 0)
|
||||||
_ = Play("BlackDialogGroup1");
|
_ = Play(_dialogGroups[0].DialogGroupName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Awaitable Play(string groupName)
|
public async Awaitable Play(string groupName)
|
||||||
{
|
{
|
||||||
|
if (IsPlaying) return;
|
||||||
if (!_dialogGroupMap.TryGetValue(groupName, out var group))
|
if (!_dialogGroupMap.TryGetValue(groupName, out var group))
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"[DialogPlayer] 그룹 없음: {groupName}");
|
Debug.LogWarning($"[DialogPlayer] 그룹 없음: {groupName}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var node = group.StartNode;
|
IsPlaying = true;
|
||||||
while (node != null)
|
try
|
||||||
{
|
{
|
||||||
await PlayNode(node);
|
var node = group.StartNode;
|
||||||
|
while (node != null)
|
||||||
|
{
|
||||||
|
await PlayNode(node);
|
||||||
|
|
||||||
if (node.Choices != null && node.Choices.Count > 0)
|
if (node.Choices != null && node.Choices.Count > 0)
|
||||||
{
|
{
|
||||||
int picked = await WaitForChoice(node);
|
int picked = await WaitForChoice(node);
|
||||||
node = node.Choices[picked].DestinationNode;
|
node = node.Choices[picked].DestinationNode;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
node = node.Next;
|
node = node.Next;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
IsPlaying = false;
|
||||||
|
}
|
||||||
|
|
||||||
Debug.Log("[DialogPlayer] 대화 종료");
|
Debug.Log("[DialogPlayer] 대화 종료");
|
||||||
}
|
}
|
||||||
|
|||||||
19
Assets/02_Scripts/Interact/DialogInteractable.cs
Normal file
19
Assets/02_Scripts/Interact/DialogInteractable.cs
Normal file
@@ -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<DialogPlayer>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void HandleActivated(ActivateEventArgs args)
|
||||||
|
{
|
||||||
|
if (_player == null || _player.IsPlaying) return;
|
||||||
|
_ = _player.Play();
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/02_Scripts/Interact/DialogInteractable.cs.meta
Normal file
2
Assets/02_Scripts/Interact/DialogInteractable.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a8a22189f0d1e5448bf3e44657410176
|
||||||
Binary file not shown.
BIN
ProjectSettings/TagManager.asset
LFS
BIN
ProjectSettings/TagManager.asset
LFS
Binary file not shown.
Reference in New Issue
Block a user