Files
WhaleAdventure_VR/Assets/My project/Dialogue Scripts/UI/NPCInteract.cs
skrwns304@gmail.com b1e85a5b89 2026-06-19 UI, UI로직
2026-06-19 14:27:40 +09:00

47 lines
1.1 KiB
C#

using UnityEngine;
[DisallowMultipleComponent]
public class NPCInteract : MonoBehaviour
{
[Header("Dialogue Data")]
[SerializeField] private DialogueData dialogue;
[Header("Reference")]
[SerializeField] private DialogueManager manager;
[Header("Settings")]
[SerializeField] private bool autoFindManager = true;
private void Awake()
{
if (manager == null && autoFindManager)
manager = FindFirstObjectByType<DialogueManager>();
}
public void Interact()
{
if (dialogue == null)
{
Debug.LogWarning($"[NPCInteract] {name}에 DialogueData가 연결되지 않았습니다.");
return;
}
if (manager == null)
{
Debug.LogWarning($"[NPCInteract] {name}에 DialogueManager가 연결되지 않았습니다.");
return;
}
manager.StartDialogueFromNPC(dialogue, transform);
}
public void SetDialogue(DialogueData newDialogue)
{
dialogue = newDialogue;
}
public void SetManager(DialogueManager newManager)
{
manager = newManager;
}
}