using DG.Tweening;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
///
/// 加载UI
///
public class LoadUI : UIBaseClass
{
///
/// 进度条
///
public Image progressBar;
///
/// 打开
///
private UnityAction onShow;
///
/// 关闭
///
private UnityAction onHide;
public override void OnShow()
{
base.OnShow();
progressBar.fillAmount = 0;
}
public override void OnHide()
{
base.OnHide();
this.onHide?.Invoke();
}
///
/// 加载
///
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();
});
});
});
}
///
/// 设置事件
///
public void SetAction(UnityAction onShow,UnityAction onHide)
{
this.onShow = onShow;
this.onHide = onHide;
}
}