Horje
loading screen unity Code Example
loading screen unity
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();
		}
	}
}




Csharp

Related
simple code to call rest api c# Code Example simple code to call rest api c# Code Example
c# break from foreach method Code Example c# break from foreach method Code Example
C# int array initial values Code Example C# int array initial values Code Example
c# add 2 arrays Code Example c# add 2 arrays Code Example
on collision enter by layer 2d unity Code Example on collision enter by layer 2d unity Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9