NewN_UAVPlane/Assets/Zion/Scripts/Adam/Components/SceneLoad.cs

50 lines
1.3 KiB
C#
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class SceneLoad : MonoSingleton<SceneLoad>
{
public GameObject loadingPanel;
public Slider loadSlider;
public Text loadingInfoText;
private void Start()
{
loadingPanel.SetActive(false);
}
public void SceneChange(string Scenename)
{
Debug.Log("Scenename---" + Scenename);
StartCoroutine(LoadScene(Scenename));
}
private IEnumerator LoadScene(string loadSceneName)
//ÉèÖÃЭ³ÌÀàÐÍ·½·¨loadlevel
{
loadingInfoText.text = "0%";
loadSlider.value = 0;
loadingPanel.SetActive(true);
AsyncOperation operation = SceneManager.LoadSceneAsync(loadSceneName);
operation.allowSceneActivation = false;
while (!operation.isDone)
{
loadSlider.value = operation.progress;
loadingInfoText.text = operation.progress + "%";
Debug.Log(operation.progress);
if (operation.progress >= 0.9f)
{
loadSlider.value = 1;
loadingInfoText.text = "100%";
operation.allowSceneActivation = true;
}
yield return null;
}
loadingPanel.SetActive(false);
}
}