UIBlackSceneController.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using DG.Tweening;
  3. using DG.Tweening.Core;
  4. using DG.Tweening.Plugins.Options;
  5. using UnityEngine;
  6. [RequireComponent(typeof(UIPanel))]
  7. public class UIBlackSceneController : MonoBehaviour
  8. {
  9. public float Alpha
  10. {
  11. get
  12. {
  13. return this._panel.alpha;
  14. }
  15. set
  16. {
  17. this._panel.alpha = value;
  18. }
  19. }
  20. private void Awake()
  21. {
  22. this._panel = base.GetComponent<UIPanel>();
  23. this._panel.alpha = 0f;
  24. }
  25. public YieldInstruction FadeTransparent(float during = 0.3f, bool ignoreTimeScale = false)
  26. {
  27. return this.FadeTo(0f, during, ignoreTimeScale);
  28. }
  29. public YieldInstruction FadeBlack(float during = 0.3f, bool ignoreTimeScale = false)
  30. {
  31. return this.FadeTo(1f, during, ignoreTimeScale);
  32. }
  33. public YieldInstruction FadeTo(float endValue, float during, bool ignoreTimeScale = false)
  34. {
  35. return DOTween.To(() => this._panel.alpha, delegate(float alpha)
  36. {
  37. this._panel.alpha = alpha;
  38. }, endValue, during).SetUpdate(ignoreTimeScale).WaitForCompletion();
  39. }
  40. public void Kill()
  41. {
  42. this._panel.DOKill(false);
  43. }
  44. private UIPanel _panel;
  45. }