대화 프로토타입
This commit is contained in:
19
Assets/02_Scripts/Communication/Dialog/DialogInteractable.cs
Normal file
19
Assets/02_Scripts/Communication/Dialog/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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b05ae7fb07619844f8a7e36f20f64ba8
|
||||
@@ -33,11 +33,10 @@ private void Awake()
|
||||
}
|
||||
}
|
||||
|
||||
public void Play()
|
||||
public async Awaitable Play()
|
||||
{
|
||||
if(_dialogGroups.Count > 0)
|
||||
_ = Play(_dialogGroups[0].DialogGroupName);
|
||||
|
||||
}
|
||||
|
||||
public async Awaitable Play(string groupName)
|
||||
@@ -71,6 +70,8 @@ public async Awaitable Play(string groupName)
|
||||
finally
|
||||
{
|
||||
IsPlaying = false;
|
||||
if (DialogHud.Instance != null)
|
||||
DialogHud.Instance.Hide();
|
||||
RestoreDefaultAnimations();
|
||||
RestoreRotations();
|
||||
}
|
||||
@@ -133,8 +134,9 @@ private async Awaitable RotateToRotation(Transform target, Quaternion targetRota
|
||||
|
||||
private async Awaitable PlayNode(DialogNode node)
|
||||
{
|
||||
var speakerName = node.Speaker != null ? node.Speaker.Name : "(누구?)";
|
||||
Debug.Log($"[{speakerName}] {node.TalkText}");
|
||||
// 화자 옆 DialogHud에 대사 표시
|
||||
if (DialogHud.Instance != null)
|
||||
DialogHud.Instance.Show(node.Speaker, node.TalkText);
|
||||
|
||||
// 보이스 재생
|
||||
if (node.Voice != null && node.Speaker != null)
|
||||
@@ -182,7 +184,7 @@ private async Awaitable<int> WaitForChoice(DialogNode node)
|
||||
Debug.LogWarning("[DialogPlayer] ChoiceHud 없음 — 0번 자동 선택");
|
||||
return 0;
|
||||
}
|
||||
return await ChoiceHud.Instance.Show(node.Speaker, node.ChoiceQuestion ,node.Choices);
|
||||
return await ChoiceHud.Instance.Show(node.ChoiceQuestion, node.Choices);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -92,10 +92,10 @@ public override void OnImportAsset(AssetImportContext ctx)
|
||||
}
|
||||
else
|
||||
{
|
||||
dn.ChoiceQuestion = GetInputPortValue<string>(gn.GetInputPortByName(DialogLineNode.PORT_QUESTION));
|
||||
dn.ChoiceQuestion = GetInputPortValue<DialogText>(gn.GetInputPortByName(DialogLineNode.PORT_QUESTION)).Value;
|
||||
for (int i = 0; i < choiceCount; i++)
|
||||
{
|
||||
var choiceText = GetInputPortValue<string>(gn.GetInputPortByName(DialogLineNode.ChoiceTextPort(i)));
|
||||
var choiceText = GetInputPortValue<DialogText>(gn.GetInputPortByName(DialogLineNode.ChoiceTextPort(i))).Value;
|
||||
var dest = GetConnectedNode(gn, DialogLineNode.ChoiceOutPort(i));
|
||||
dn.Choices.Add(new DialogChoice
|
||||
{
|
||||
|
||||
@@ -61,11 +61,12 @@ protected override void OnDefinePorts(IPortDefinitionContext context)
|
||||
}
|
||||
|
||||
// 가변 N지선다
|
||||
context.AddInputPort<string>(PORT_QUESTION).WithDisplayName("Choice Question").Build();
|
||||
// (string 포트는 GraphToolkit 기본 에디터의 IME 중복입력 버그가 있어 DialogText로 통일)
|
||||
context.AddInputPort<DialogText>(PORT_QUESTION).WithDisplayName("Choice Question").Build();
|
||||
|
||||
for (int i = 0; i < choiceCount; i++)
|
||||
{
|
||||
context.AddInputPort<string>(ChoiceTextPort(i))
|
||||
context.AddInputPort<DialogText>(ChoiceTextPort(i))
|
||||
.WithDisplayName($"Choice {i + 1} Text")
|
||||
.Build();
|
||||
AddExecOutput(context, ChoiceOutPort(i), $"Choice {i + 1} →");
|
||||
|
||||
Reference in New Issue
Block a user