60 lines
1.9 KiB
C#
60 lines
1.9 KiB
C#
using DG.Tweening;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.Video;
|
|
|
|
public class LoadingPanel : MonoBehaviour
|
|
{
|
|
public VideoPlayer player;
|
|
public Image image_Bg;
|
|
public Action actionEnd;
|
|
public float fadeTime = 1.3f;
|
|
|
|
private void Start()
|
|
{
|
|
// ⭐ 视频播放期间预载大厅主面板:把 HomeUIRes 的加载提前到这段视频等待时间里,
|
|
// 登录成功 UILoginPanel.Succeed() 的 ShowAsync(HomeMainPanel) 命中缓存秒开,
|
|
// 不再出现"登录成功后进大厅白等"。
|
|
StartCoroutine(PreloadHomeMainRoutine());
|
|
}
|
|
|
|
/// <summary>预载大厅主面板:等 UIManager 就绪后发起(视频这段时间足够 HomeUIRes 加载完)</summary>
|
|
private IEnumerator PreloadHomeMainRoutine()
|
|
{
|
|
while (UIManager.Instance == null)
|
|
yield return null;
|
|
yield return null; // 等 UIManager 初始化完成(地址表装载)
|
|
UIManager.Instance.PreloadPanel(UIPanel.HomeMainPanel);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 进入条进度值
|
|
/// </summary>
|
|
/// <param name="count">最大100 100时直接删除</param>
|
|
public void LoadBar(int count)
|
|
{
|
|
if (count == 100)
|
|
{
|
|
// ⭐ 兜底再预载一次:若启动时 UIManager 尚未就绪导致首次发起无效,这里补上
|
|
if (UIManager.Instance != null)
|
|
UIManager.Instance.PreloadPanel(UIPanel.HomeMainPanel);
|
|
GameManager.Instance.btn_Skip.gameObject.SetActive(false);
|
|
Destroy(gameObject, fadeTime);
|
|
if (player.gameObject.activeSelf)
|
|
{
|
|
player.GetComponent<RawImage>().DOFade(0, fadeTime);
|
|
}
|
|
if (image_Bg.gameObject.activeSelf)
|
|
{
|
|
image_Bg.DOFade(0, fadeTime);
|
|
|
|
}
|
|
actionEnd?.Invoke();
|
|
}
|
|
|
|
}
|
|
}
|