30 lines
754 B
C#
30 lines
754 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using TMPro;
|
|
using DG.Tweening;
|
|
public class PlayerDeathMessage : MonoBehaviour
|
|
{
|
|
[SerializeField] private TMP_Text playerDeathText;
|
|
[SerializeField] private CanvasGroup group;
|
|
private bool isChangingText;
|
|
private void Awake() => ResetText();
|
|
|
|
private void Update()
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(playerDeathText.text) && !isChangingText)
|
|
{
|
|
isChangingText = true;
|
|
group.DOFade(0, 3.0f).SetDelay(2.0f).OnComplete(() => ResetText());
|
|
}
|
|
}
|
|
|
|
private void ResetText()
|
|
{
|
|
isChangingText = false;
|
|
playerDeathText.text = "";
|
|
group.alpha = 1.0f;
|
|
}
|
|
}
|