using System.Collections; using UnityEngine; using TMPro; using UnityEngine.UI; public class DialogManager : MonoBehaviour { public GameObject dialogPanel; public TextMeshProUGUI dialogText; // Use TextMeshProUGUI instead of Text public PlayerMovement playerMovement; private void Start() { dialogPanel.SetActive(false); // Hide on start } Coroutine dialogCoroutine = null; public void ShowDialog(string message) { print("should be showing dialog"); if (dialogCoroutine != null) { StopCoroutine(dialogCoroutine); } dialogCoroutine = StartCoroutine(ShowDialogCoroutine(message)); dialogPanel.SetActive(true); playerMovement.moveAllowed = false; } // Coroutine to show dialog. Each letter is displayed one by one IEnumerator ShowDialogCoroutine(string message) { dialogText.text = ""; // Clear previous text dialogPanel.SetActive(true); playerMovement.moveAllowed = false; foreach (char letter in message) { dialogText.text += letter; // Append each letter // KRAUSI MACH SOUND HIER DRINNE REIN PRO LETTER yield return new WaitForSeconds(0.05f); // Wait for a short duration before showing the next letter } dialogCoroutine = null; } public void HideDialog() { dialogPanel.SetActive(false); playerMovement.moveAllowed = true; } }