Комментировать не буду:
using UnityEngine;
public class LevelLoadScreen : MonoBehaviour
{
public Texture2D background;
public string levelNameToLoad;
private AsyncOperation _loadingProgress;
private bool _readeyToDestroy = false;
public void Start()
{
DontDestroyOnLoad(gameObject);
_loadingProgress = Application.LoadLevelAsync(levelNameToLoad);
}
public void Update()
{
if (_readeyToDestroy)
{
Destroy(gameObject);
}
}
public void OnGUI()
{
if (background)
{
GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), background, ScaleMode.StretchToFill);
}
GUI.Box(new Rect(10, Screen.height / 2 - 20, (Screen.width - 20) * _loadingProgress.progress, 40), "");
if (_loadingProgress.isDone)
{
if(GUI.Button(new Rect(Screen.width/2 - 100, Screen.height / 2 - 10, 200, 20), "Continue"))
{
_readeyToDestroy = true;
}
}
}
}