2026-06-19 UI, UI로직
This commit is contained in:
47
Assets/My project/Dialogue Scripts/UI/NPCInteract.cs
Normal file
47
Assets/My project/Dialogue Scripts/UI/NPCInteract.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user