- Home /
How to keep "Loading" animation from freezing while loading a large level?
I have a simple scene with an animated "loading" spinner (it's a uGUI animated sprite) along with a script that loads my actual game scene. The problem is that the loading animation freezes while Unity is loading the game scene -- several seconds of lag. Is there a way to keep the loading animation smooth while Unity loads up the game scene?
Answer by goibon · Aug 25, 2015 at 04:25 PM
Have you considered using Application.LoadLevelAsync ? That should allow your current scene to run while loading the next.
Note that Application.LoadLevelAsync
is a pro feature in Unity versions prior to Unity5.
To get better performance of your loading screen scene you can opt to use Application.backgroundLoadingPriority to lower the priority of loading data asynchronously.
Note that lower priorities give better performance of current scene at the cost of longer load times.
Thanks goibon, it didn't completely fix it, but it's slightly better. I have the LoadLevelAsync set on a couple second delay, so I can first see the smooth animation of my loader spinner, but when the LoadLevelAsync kicks in, it gets really choppy -- like maybe a frame every 2 seconds or so. Before it was dead frozen, so this is technically an improvement, but I was hoping for it to be smooth all the way through. Any other ideas? (FYI, I tested a complete re-build; I didn't merely test in the Editor)
Hmm.. Ok well I'm glad you did a rebuild because the editor will not give a smooth result. Perhaps you could try lowering the priority of the loading, it will cause a longer load time but should result in better performance. See here for reference: http://docs.unity3d.com/ScriptReference/Application-backgroundLoadingPriority.html
That was a another noticeable but marginal improvement. However, I happened to notice that the problem went completely away when I scrapped all my lightmaps. Then I noticed my Realtime GI resolution was set to 8 texels/unit ins$$anonymous$$d of the default 2. I changed to 2, rebaked, and now it seems pretty good. $$anonymous$$y loading animation isn't butter-smooth when then the loading kicks in, but it's pretty good and totally acceptable. Plus, my level loads faster so it's almost a moot issue now.
Both the LoadLevelAsync and ThreadPriority.Low were great tips, so thanks so much for those!
Answer by Foulcloud · Aug 25, 2015 at 04:26 PM
As goibon mentioned, you will need to use LoadLevelAsync to do this. In unity 4, this is only available in the Pro versions.
Your answer

Follow this Question
Related Questions
Can't get 4.6 GUI Button to Load Scene (Solved) 1 Answer
Load/Change scene with UI Button 1 Answer
Problem with Load Level Script 1 Answer
Drawing-Order in 2D topdown game 2 Answers
button drawn last not triggered 0 Answers