Unity 5 Loading Screen Script?
Hey, I am trying to make a loading screen just like this:
Problem is, I don't know how to do that, and I am not that good at programming…
If you have anything, pls make me the script, and give me descriptive details.
Answer by PictonicStudio · Oct 17, 2015 at 07:13 AM
public Texture2D ProgressBar;
private AsyncOperation async = null;
//Always start this coroutine in the start function
private void Start()
{
StartCoroutine(LoadLevel("LevelName"));
}
//CoRoutine to return async progress, and trigger level load.
private IEnumerator LoadLevel(string Level)
{
Application.LoadLevelAsync(Level);
yield return async;
}
private void OnGUI()
{
// Check if it's loading;
if (async != null)
{
GUI.DrawTexture(new Rect(0, 0, 100 * async.progress, 50), ProgressBar);
}
}
And Just for future tips, please don't sound so demanding. We do this for free, and are just inhibiting you from learning how to do it your self.
WTH! not even a "thank you" and then you even ask another question o_0
I for one would like to thank you for your code example as well taking OPs rude question/response like a professional. tips virtual hat to you
This doesn't work as of 2016, too much obsolete code
Answer by jamesccc · Oct 20, 2015 at 04:38 PM
IEnumerator LoadingLevel (int i) {
Async = Application.LoadLevelAsync (i);
yield return Async;
}
void OnGUI () {
if (Async != null) {
GUI.DrawTexture (new Rect (0, 0, 100, 50), ProgressBarEmpty);
GUI.DrawTexture (new Rect (0, 0, 100* Async.progress, 50), ProgressBarFull);
}
}
I dun thk its a pro as it works fine on 5.2 here.
Hope it helps. cheers