“Lade der Bildschirmeinheit” Code-Antworten

Lade der Bildschirmeinheit


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

Lade der Bildschirmeinheit

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

Ähnliche Antworten wie “Lade der Bildschirmeinheit”

Fragen ähnlich wie “Lade der Bildschirmeinheit”

Weitere verwandte Antworten zu “Lade der Bildschirmeinheit” auf C#

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen