Trying to do a scene loading bar in C# for Unity 5 and having major issues... please assist!

Ok so basically I’ve been at this all day and no matter what I’ve tried I keep getting red warnings.
The below script (assembled from various forum posts) seems to work perfectly fine but I need
to get this to run on awake in a blank scene or a loading screen:

public class LoadingScreen : MonoBehaviour {

    public Texture2D emptyProgressBar; // Set this in inspector.
    public Texture2D fullProgressBar; // Set this in inspector.
    public string LevelName; // Set this in inspector.

    private AsyncOperation async = null; // When assigned, load is in progress.
    private IEnumerator LoadALevel(string levelName)
    {
        async = Application.LoadLevelAsync(levelName);
        yield return async;
    }
    void OnGUI()
    {
        if (async != null)
        {
            GUI.DrawTexture(new Rect(0, 0, 100, 50), emptyProgressBar);
            GUI.DrawTexture(new Rect(0, 0, 100 * async.progress, 50), fullProgressBar);
            GUI.skin.label.alignment = TextAnchor.MiddleCenter;
            GUI.Label(new Rect(0, 0, 100, 50), string.Format("{0:N0}%", async.progress * 100f));
        }
    }

}

You need to start the coroutine. It doesn’t start by itself. Or you can make Start a coroutine and yield immediately.

Based on the previous example I had I noticed that if I had the load in Awake, I would get no overlay.

Based on our conversation in comments, here’s a revised version of your script. It works for me but it was very, very subtle until I made the rect bigger. I added a fullscreen checkbox that you can enable to witness the loading in full glory (on by default). I also added a debug checkbox to more easily see output in the console so you can figure out what could be going wrong in case it doesn’t load the level etc (also on by default). Finally, I added a field where you manually can enter the position of the progress bar.

Note that I only tested this against the super simple scenes I got available. A scene load in 1-2 frames so it just flickers and then you are at the next level. Update the script, see if anything happens and see if there is anything in the log.

using UnityEngine;
using System.Collections;

public class LoadingScreen : MonoBehaviour
{
    // Set this in inspector.
    public Texture2D emptyProgressBar;
    public Texture2D fullProgressBar;
    public string LevelName;
    public Rect position = new Rect(0, 0, 100, 50);
    public bool fullScreen = true;
    public bool debug = true;

    // When assigned, load is in progress.
    private AsyncOperation async = null;

    IEnumerator Start()
    {
        dbg("Level '{0}' loading...", LevelName);
        yield return async = Application.LoadLevelAsync(LevelName);
    }

    void OnGUI()
    {
        if (fullScreen)
            ProgressBar(0, 0, Screen.width, Screen.height);
        else
            ProgressBar(position.x, position.y, 
                position.width, position.height);
    }

    void ProgressBar(float x, float y, float width, float height)
    {
        if (async == null)
            return;

        if (Event.current.type == EventType.Repaint)
            dbg("Level progress: {0:N0}%", async.progress * 100f);

        GUI.DrawTexture(new Rect(x, y, width, height), emptyProgressBar);
        GUI.DrawTexture(new Rect(x, y, width * async.progress, height), fullProgressBar);
        GUI.skin.label.alignment = TextAnchor.MiddleCenter;
        GUI.Label(new Rect(x, y, width, height), string.Format("{0:N0}%", async.progress * 100f));
    }

    void dbg(string fmt, params object[] args)
    {
        if (debug)
            print(string.Format(fmt, args));
    }
}