UILevelNameController.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System;
  2. using System.Collections;
  3. using DG.Tweening;
  4. using UnityEngine;
  5. public class UILevelNameController : MonoBehaviour
  6. {
  7. public UILabel Label
  8. {
  9. get
  10. {
  11. return this._label;
  12. }
  13. }
  14. public Coroutine Show(string levelName, int fontSize, float duration, bool withBackground = true)
  15. {
  16. return base.StartCoroutine(this.ShowCoroutine(levelName, fontSize, duration, withBackground));
  17. }
  18. private IEnumerator ShowCoroutine(string levelName, int fontSize, float duration, bool withBackground = false)
  19. {
  20. this._background.SetActive(withBackground);
  21. this._label.alpha = 0f;
  22. this._label.text = levelName;
  23. this._label.fontSize = fontSize;
  24. this._label.gameObject.SetActive(true);
  25. yield return DOTween.To(() => this._label.alpha, delegate(float a)
  26. {
  27. this._label.alpha = a;
  28. }, 1f, duration).WaitForCompletion();
  29. yield return new WaitForSeconds(1f);
  30. yield return DOTween.To(() => this._label.alpha, delegate(float a)
  31. {
  32. this._label.alpha = a;
  33. }, 0f, duration).WaitForCompletion();
  34. this._label.gameObject.SetActive(false);
  35. yield break;
  36. }
  37. [SerializeField]
  38. private UILabel _label;
  39. [SerializeField]
  40. private GameObject _background;
  41. }