batteryDiagnosis/Assets/Scripts/testscene.cs

49 lines
1.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class testscene : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
LoadSceneWithProgress("TestScene1");
}
// Update is called once per frame
void Update()
{
}
//Òì²½¼ÓÔØ³¡¾°
public void LoadSceneAsync(string sceneName)
{
StartCoroutine(LoadScene(sceneName));
}
IEnumerator LoadScene(string sceneName)
{
AsyncOperation operation = Application.LoadLevelAsync(sceneName);
while (!operation.isDone)
{
yield return null;
}
}
//Òì²½¼ÓÔØ³¡¾°²¢Ìí¼Ó½ø¶ÈÌõ
public void LoadSceneWithProgress(string sceneName)
{
StartCoroutine(LoadSceneWithProgressCoroutine(sceneName));
}
IEnumerator LoadSceneWithProgressCoroutine(string sceneName)
{
AsyncOperation operation = Application.LoadLevelAsync(sceneName);
while (!operation.isDone)
{
float progress = Mathf.Clamp01(operation.progress / 0.9f);
Debug.Log(progress);
yield return null;
}
}
}