UISplashController.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using System;
  2. using System.Collections;
  3. using DG.Tweening;
  4. using UnityEngine;
  5. public class UISplashController : MonoBehaviour
  6. {
  7. private void Start()
  8. {
  9. Log.Info("Loading the start scene");
  10. this._asyncOperation = LevelManager.LoadScene("ui_start");
  11. this._asyncOperation.allowSceneActivation = false;
  12. base.StartCoroutine(this.Sequence0());
  13. }
  14. private void Update()
  15. {
  16. if (this._asyncOperation != null && this._asyncOperation.isDone)
  17. {
  18. Log.Info("Loaded the start scene");
  19. }
  20. }
  21. private IEnumerator Sequence0()
  22. {
  23. if (UILanguage.IsSimplifiedChinese)
  24. {
  25. yield return DOTween.To(delegate(float a)
  26. {
  27. this._widgets[0].alpha = a;
  28. }, 0f, 1f, this._fade).WaitForCompletion();
  29. yield return new WaitForSeconds(5f);
  30. yield return DOTween.To(delegate(float a)
  31. {
  32. this._widgets[0].alpha = a;
  33. }, 1f, 0f, this._fade).WaitForCompletion();
  34. yield return new WaitForSeconds(this._fade);
  35. }
  36. for (int i = 1; i < this._widgets.Length; i++)
  37. {
  38. int iCopy = i;
  39. yield return DOTween.To(delegate(float a)
  40. {
  41. this._widgets[iCopy].alpha = a;
  42. }, 0f, 1f, this._fade).WaitForCompletion();
  43. yield return new WaitForSeconds((i == 0) ? 5f : this._duration);
  44. yield return DOTween.To(delegate(float a)
  45. {
  46. this._widgets[iCopy].alpha = a;
  47. }, 1f, 0f, this._fade).WaitForCompletion();
  48. if (iCopy != this._widgets.Length - 1)
  49. {
  50. yield return new WaitForSeconds(this._fade);
  51. }
  52. }
  53. this._asyncOperation.allowSceneActivation = true;
  54. yield break;
  55. }
  56. private void OnApplicationPause(bool pause)
  57. {
  58. if (!pause && this._asyncOperation != null)
  59. {
  60. this._asyncOperation.allowSceneActivation = true;
  61. }
  62. }
  63. [SerializeField]
  64. private UIWidget[] _widgets;
  65. [SerializeField]
  66. private float _fade;
  67. [SerializeField]
  68. private float _duration;
  69. private AsyncOperation _asyncOperation;
  70. }