Forcing Graphics Redraw?

tldr; Is there a way to force an immediate graphics redraw?

I have a splash screen that I use several places during scene/asset loading times. Code is something like this.

SplashScreen.enabled = true;
LoadStuff(); //This takes a few seconds
SplashScreen.enabled = false;

However the SplashScreen is NOT shown during loading (likely due to Render only occurring at the and of the Frame which it doesn’t reach due to being stuck in LoadStuff() method)

What I would like to do is force a graphics redraw here

SplashScreen.enabled = true;
FORCE_REDRAW();
Load(); //This takes a few seconds
SplashScreen.enabled = false;

Is there any way to force a graphics redraw? Canvas.ForceUpdateCanvases() and Camera.main.Render() do not work.

Thanks in advance.

Maybe I am misunderstanding this, but couldn’t you do what you want by using a coroutine and waiting for the next frame to call the Load method?

splashScreen.enabled = true;
StartCoroutine(LoadWrapper());


private IEnumerator LoadWrapper()
    {
        yield return null;
        Load();
        SplashScreen.enabled = false;

    }
1 Like

I think what you posted would work. I may have to go with that.

I’ve been trying to avoid asyncloading or co-routines or frame delays because can cause un-robust problematic code if you aren’t careful.

Thanks though.

Hi. FYI I ended up using a similar approach for my loading screen, i.e. coroutine to wait before loading. Kinda silly there isn’t a better way to do this IMHO

1 Like