- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using TMPro;
- public class DialogUIController : MonoBehaviour
- {
- public TextMeshProUGUI textObject;
- float timer;
- public float maxTimer = 5;
- private bool txtTicked;
-
- void Awake()
- {
- DialogController.dialogSkipped += DialogController_dialogSkipped;
- timer = maxTimer;
- }
- private void DialogController_dialogSkipped(DialogueMessage msg, DialogController controller)
- {
- if (textObject != null)
- {
- if (string.IsNullOrEmpty(msg.author))
- {
- textObject.text = msg.content;
- } else
- {
- textObject.text = $"{msg.author} : {msg.content}";
- }
- timer = maxTimer;
- txtTicked = true;
- }
- }
-
- void Update()
- {
- if (timer <= 0)
- {
- timer = maxTimer;
- if (txtTicked)
- {
- txtTicked = false;
- textObject.text = string.Empty;
- }
- } else
- {
- timer -= Time.deltaTime;
- }
- }
- }