39 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System.Collections;
 | |
| using System.Collections.Generic;
 | |
| using UnityEngine;
 | |
| using UnityEngine.SceneManagement;
 | |
| using UnityEngine.UI;
 | |
| 
 | |
| public class View_Panel2Attatch : MonoBehaviour
 | |
| {
 | |
|     public static View_Panel2Attatch view_Panel2Attatch;
 | |
|     public GameObject subject;
 | |
|     //加载
 | |
|     public GameObject ObjLoadingScene;//加载
 | |
|     public Slider progressBar;//进度条
 | |
|     public Text progressDisplay;//进度显示 
 | |
| 
 | |
|     private void Awake()
 | |
|     {
 | |
|         view_Panel2Attatch = this;
 | |
|     }
 | |
|     public IEnumerator Loadscene(string _scence)
 | |
|     {
 | |
|         ObjLoadingScene.SetActive(true);
 | |
|         AsyncOperation operation = SceneManager.LoadSceneAsync(_scence);
 | |
|         operation.allowSceneActivation = false;
 | |
|         while (!operation.isDone)
 | |
|         {
 | |
|             progressBar.value = operation.progress;
 | |
|             progressDisplay.text = "努力加载中..." + operation.progress * 100 + "%";
 | |
|             if (operation.progress >= 0.9f)
 | |
|             {
 | |
|                 progressBar.value = 1;
 | |
|                 operation.allowSceneActivation = true;
 | |
|             }
 | |
|             yield return null;
 | |
|         }
 | |
|     }
 | |
| 
 | |
| }
 |