“Memuat Unity Layar” Kode Jawaban

Memuat Unity Layar


IEnumerator load(){
    yield return null;

    //Begin to load the Scene you specify
    AsyncOperation asyncOperation = SceneManager.LoadSceneAsync(sceneIndex);
    //Don't let the Scene activate until you allow it to
    asyncOperation.allowSceneActivation = false;
    Debug.Log("Pro :" + asyncOperation.progress);
    //When the load is still in progress, output the Text and progress bar
    while (!asyncOperation.isDone)
    {
        //Output the current progress
        Debug.Log("Loading progress: " + (asyncOperation.progress * 100) + "%");

        // Check if the load has finished
        if (asyncOperation.progress >= 0.9f)
        {
            //Change the Text to show the Scene is ready
            asyncOperation.allowSceneActivation = true;
        }

        yield return null;
    }
}

Poor Puffin

Memuat Unity Layar

using System.Collections;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using TMPro;

public class LoadingScreen : MonoBehaviour
{
	[HideInInspector]
	private TextMeshProUGUI loadingText;
	[HideInInspector]
	private Slider loadingSlider;

	public void LoadScene(int sceneNumber)
	{
		StartCoroutine(LoadSceneAsync(sceneNumber));
	}

	IEnumerator LoadSceneAsync(int sceneIndex)
	{
		AsyncOperation operation = SceneManager.LoadSceneAsync(sceneIndex);

		while (!operation.isDone)
		{
			Debug.Log("Operation progress");

			float progress = Mathf.Clamp01(operation.progress / 0.9f);

			loadingText.text = Mathf.RoundToInt(progress * 100) + "%";
			loadingSlider.value = progress;

			yield return new WaitForEndOfFrame();
		}
	}
}
MunchDuster

Jawaban yang mirip dengan “Memuat Unity Layar”

Pertanyaan yang mirip dengan “Memuat Unity Layar”

Lebih banyak jawaban terkait untuk “Memuat Unity Layar” di C#

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya