How to do a percentage loading screen?

So we’ve all seen tons of tutorials and so on about how to do a loading bar in Unity, but what about doing percentages? I quite liked that at times because you’re not relying on any fancy graphics to track progress, some older games did this I remember but most seem to either just use loading bars or just have static loading screens without letting you know if the game is even loading or not.

How would this work? Does anyone know? I’ve posted a video of the red alert 2 installation menu to give you an idea of what I’m thinking of.

It’s just a different representation of the loading progress and does not require anything special.

If you structure this properly, you could seperate that coroutine which queries the progress property of an async operation by making it an independent entity in your project. This could then update an arbitary representation which does only listen for updates of the progress and hence do not re-implement all the querying logic. Let it be a simple bar, a bar with percentage or even some complex visualization.

Pretty much the MVC / MVP pattern.

So actually - in other words - what you’re asking for is the base for all the loading bars, as these usually depend on some value in order to work at all, unless you fake it somehow.

1 Like

Ahhh, thanks, so I just need to transfer the usual code to a string rather than a loading bar image if I understand correctly, in that case it may be even easier than doing a progress bar itself.

Exactly. Instead of using the progress value to scale or fill graphical content, you’d just set it as a text value for a label. As mentioned, if you seperate this, you can seperate this like

LogicalComponent:

  • runs a routine that queries the progress value
  • if it has changed, raises an event with the value

VisualizingComponent:

  • waits for the event of the LogicalComponent to be thrown and uses the progress value in its own way…

The second component would no longer care about how and when the value is determined. The only thing it cares about is that it’ll eventually be updated and all it does is to care about how the new value will be rendered to the user (or whatever you want to do with it).

it could be a component that logs the value, one that writes it to a label. Or one that converts it to fancy stuff, a progress-bar component… any of those combined or stacked up.

This is very flexible and the visualizing component can simply be exchanged, whereas the logical component and it’s code does not need to be touched at all.

1 Like