using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; using DG.Tweening; public class KillMessage : MonoBehaviour { private TMP_Text text; private Color normalColor; private Color fadeOutColor; public float startingScale = 5.0f; private void Awake() { text = gameObject.GetComponent(); normalColor = text.color; fadeOutColor = text.color; fadeOutColor.a = 0; } // Start is called before the first frame update void OnEnable() { text.color = normalColor; gameObject.transform.localScale = Vector3.one * startingScale; transform.DOScale(Vector3.one, 0.15f).SetEase(Ease.OutExpo).OnComplete(() => FadeOut()); } public void SetText(string message) { text.text = message; } void FadeOut() { text.DOFade(0, 0.25f).SetDelay(0.25f).SetEase(Ease.Linear).OnComplete(() => DisableObject()); } void DisableObject() { gameObject.SetActive(false); } }