using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
///
/// 假进度
///
public class ShiCaoLoadingPanel : MonoSingleton
{
public Slider slider;
public Text ProgressText;
public Text TipText;
public GameObject MaskGo;
[HideInInspector]
public float _duration = 1f;//加载持续时间
[HideInInspector]
public bool _loading = false;
public Action _loadingOver;
void Start()
{
// //测试
// SetSteat(true, 3, () => {
// Debug.Log("加载完毕");
//});
}
void Update()
{
if (_loading)
{
if (slider.value < 1)
{
float value = 1 / _duration * Time.deltaTime;
slider.value += value;
ProgressText.text = (int)(slider.value * 100) + " %";
}
else
{
_loadingOver.Invoke();
SetSteat(false, 3);
slider.value = 0;
}
}
}
///
/// 设置状态
///
/// 打开关闭
/// 加载持续时间
public void SetSteat(bool bo,int duration, Action action=null)
{
_loadingOver = action;
_duration =duration;
_loading = bo;
MaskGo.SetActive(bo);
}
}
unity 假进度面板
关注
打赏