- Home /
Why is SceneLoading slow with big Animations?
So i am working on a simple game. I have a Scene with a ScrollView handler that generates Content for a ScrollView. This handler Holds 3 Gameobjects, that use an Animation. All of these Animations are just animating the Image. All of these Animations have over 90 Keyframes because the animation is over 90 Images long for all of these 3 Gameobjects. When i remove those 3 Objects out of the ScrollView handler, the Scene loads seasmlessly. When i have these 3 Objects in the ScrollView handler, the Scene Loading takes up to 2 Seconds. This game is supposed to be an Android game and I want to have seamless Scene transitions without a Loading Screen because in this case that would be purely annoying. How would I fix this?
All Help would be highly appreciated. Im stuck with this Problem for many Days now and I really dont like to go the way with Async Level Loading and creating a Loading Screen.
Answer by ryanmillerca · Nov 23, 2020 at 01:55 PM
It sounds like you're using sprite animations. 90 images x3 gameobjects is 270 images. How big are these images? Are they compressed? Are they sprite packed or atlassed? If each image is 4mb for example, then you've added 1gb of textures that need to be loaded into memory when you start the game. This is the reason your startup is slow - you're simply loading a lot of data with that animation. The solution to reduce load times is to reduce the amount of texture data in your animation - by compressing those textures, restructuring your animation to use less images, or find another method (rigged/puppet animation or video players).
Each Animations Frames is more or less 10kb big. They have been compressed as hard as possible without losing detail. Together those 4 Animations Images are like 4mb of data. But i have not tried using an atlas or Videoplayers. But thats probably something I will have to do. Any other tips?
10kb as the file size of your source PNG/JPG/etc files is one thing, but they become a different format when they go into a game engine. Compressed formats like PNG don't live on the graphics card, they get turned into DXT/ETC/PVRTC/etc other formats that read/write faster depending on your target platform. A good starting point to fix this is to pack your textures https://docs.unity3d.com/2017.3/Documentation/$$anonymous$$anual/SpritePacker.html and set the image compression reasonably high in your project asset settings (crunched, compressed, low/medium quality is a good start).
Turn on profiler before you load the scene and watch the $$anonymous$$emory section. Back to the original post, your scene loading is slow because there's a lot of data to be loaded using the frame-by-frame animation approach. Please accept my answer if you feel it's accurate, thanks.