您当前的位置: 首页 >  unity

云小川

暂无认证

  • 4浏览

    0关注

    78博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

unity 假进度面板

云小川 发布时间:2022-08-16 18:04:55 ,浏览量:4

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);
    }

}

关注
打赏
1663746399
查看更多评论
立即登录/注册

微信扫码登录

0.0369s