DestroyMiss.cs 557 B

123456789101112131415161718192021222324
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using TMPro;
  5. public class DestroyMiss : MonoBehaviour
  6. {
  7. public float stayTime;
  8. [HideInInspector]
  9. public float time;
  10. public TextMeshProUGUI text;
  11. private void Update()
  12. {
  13. time += Time.deltaTime;
  14. transform.position += Vector3.up * Time.deltaTime;
  15. Color color = text.color;
  16. color.a = 1 - time / 2;
  17. text.color = color;
  18. if (time >= stayTime)
  19. {
  20. gameObject.SetActive(false);
  21. }
  22. }
  23. }