67 lines
1.4 KiB
C#
67 lines
1.4 KiB
C#
using DG.Tweening;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
using UnityEngine.UI;
|
|
|
|
/// <summary>
|
|
/// 加载UI
|
|
/// </summary>
|
|
public class LoadUI : UIBaseClass
|
|
{
|
|
/// <summary>
|
|
/// 进度条
|
|
/// </summary>
|
|
public Image progressBar;
|
|
|
|
/// <summary>
|
|
/// 打开
|
|
/// </summary>
|
|
private UnityAction onShow;
|
|
|
|
/// <summary>
|
|
/// 关闭
|
|
/// </summary>
|
|
private UnityAction onHide;
|
|
|
|
public override void OnShow()
|
|
{
|
|
base.OnShow();
|
|
progressBar.fillAmount = 0;
|
|
}
|
|
|
|
public override void OnHide()
|
|
{
|
|
base.OnHide();
|
|
this.onHide?.Invoke();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载
|
|
/// </summary>
|
|
public void Load()
|
|
{
|
|
this.onShow?.Invoke();
|
|
DOTween.To(() => progressBar.fillAmount, x => progressBar.fillAmount = x, 0.2f, 0.1f).OnComplete(() =>
|
|
{
|
|
DOVirtual.DelayedCall(1, () =>
|
|
{
|
|
DOTween.To(() => progressBar.fillAmount, x => progressBar.fillAmount = x, 1, 0.1f).OnComplete(() =>
|
|
{
|
|
HideMe();
|
|
});
|
|
});
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置事件
|
|
/// </summary>
|
|
public void SetAction(UnityAction onShow,UnityAction onHide)
|
|
{
|
|
this.onShow = onShow;
|
|
this.onHide = onHide;
|
|
}
|
|
}
|