设置UI
设置背景图(将图片转化为精灵),设置UI摄像机,CullingMask改为UI,将projection改为正交(orthographic),canvas改为rendermode改为camera,UIscaleMode改为固定屏幕大小(Scale With Screen Size)
AsyncOperation
变量 | 描述 |
---|---|
allowSceneActivation | 允许场景一准备就激活。 |
isDone | 加载结束了吗?(仅读) |
priority | 优先级允许您调整异步操作调用的顺序。 |
progress | 加载进展。(仅读) |
实现
/**
*
*
* Title:
*
* description:
* 视图层:场景加载(异步加载)
*
* Date:
*
* version:
*
* modify Recoder:
*
*
**/
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class View_LoadingScense : MonoBehaviour
{
public Slider SliLoadingProgress;//进度条控件
private float _FloProgressNumber;//进度数值
private AsyncOperation _AsyOper;
// Start is called before the first frame update
void Start()
{
StartCoroutine("LoadingScenesProgress");
}
//异步加载协
IEnumerator LoadingScenesProgress()
{
SceneManager.LoadScene("2_LogonScenes");
_FloProgressNumber = _AsyOper.progress;
yield return _AsyOper;
}
// Update is called once per frame
//显示进度条
void Update()
{
if (_FloProgressNumber<=1)
{
_FloProgressNumber += 0.01f;
}
SliLoadingProgress.value = _FloProgressNumber;
}
}