Forum rules - please read before posting.

Super Long Loading Time Between Scenes

Hello!
Been developing a 2D game and as I progressed I realized that the loading time between the scenes was becoming longer and longer until it reached about half a minute! Using the profiler, I discovered that the size of global objects is way, way larger than I thought. My Player sprites alone amount to just less than 2GB!! The global sound objects amounted to about 400MB but I was able to easily cut them down to less than 50MG by compressing them (and doing some other optimization).
1. Now, is the size of my global objects the main reason of this long scene loading time?
2. If yes, what can I do about the Player sprites! They're not even that large at all when in Windows Explorer, but somehow they eat huge memory space (Note: I set Player sprite resolution to 2048, which is the lowest resolution giving satisfactory quality).
3. Any other suggestions to optimize my game?
Below: Most of the texture 2D objects are suspected to be global (such as Player sprites). 649 texture 2D objects amounting to a size of almost 2GB!
https://prnt.sc/qk9xvp
Below: A player sprite with a size of about 5MB, but there are hundreds of sprites.
https://prnt.sc/qk9y1t
Below: Working on the game!
https://prnt.sc/qk9zum

Comments

  • Oh, and thank you for your time reading My post. :) If you can help that will be very much appreciated!

  • Large memory sizes will affect your game's loading times wherever they come from, but this is true of all Unity games - not specifically to AC.

    Compressing your textures, enabling mipmaps, and using sprite atlases are all common techniques to optimise your game's performance - see Unity's own documentation on this topic here.

    There are also a number of things you can do that are specific to AC. See the Manual's "Performance and optimisation" chapter for details - though I'd recommend going through the "standard" Unity optimisation tips first.

  • Thank you so much Chris for giving me advice on where to start!

  • The tips are working like a charm and I was able to quickly cut down memory usage tremendously (e.g. using atlases + crunch compression). One strange phenomena though is that loading time gets down to exactly 12 seconds and stops there. It is now exactly 12 seconds for moving between any two scenes in my entire game. Not a second more; not a second less. Very weird.

  • Also: the first time I access any scene, it loads within one second only (only the very first time)! Then the 12-second loading time rule starts from second time on.

  • As in, once the Player prefab has been spawned, things take longer?

    Sounds like it could be related to them, then. As a quick test, assign the 2D Demo's Player prefab, Brain2D, in the Settings Manager's Player field and see if the same thing happens (ignore any animation issues).

    If not, how many animations / sprites make up your own Player prefab? See the Manual's last comment about using Timeline for one-off animations in order to reduce the number in their Animator Controller.

    It's also possible to use local Players in individual scenes, and these can have separate Animator Controllers in cases you want the Player to have access to animations specific to that scene.

  • Switching to Brain did not solve it, BUT deleting all speech audio files did! The loading time instantly went down to one second or a bit less. Currently I'm using the Resources folder for my speech audio files. Will using AssetBundles resolve the issue?

  • It worked!! It WAS a speech problem. And using the AssetBundle was not even an option prior to AC v1.66. Thank you Chris for making this better and better over time

  • Okay now here is a weird problem I am facing. I don't have any performance issues anymore. However, every time I export my speech audio files into AssetBundles a minority of my speech audios never play in the game. I can recognize no specific patterns why some files (majority) would work and some (a minority) wouldn't. And not that the not-working files are even the same every time (They change from time to time as make a new attempt to export to AssetBundles)!
    Any idea what is going on?
    Thanks!

  • edited January 2020

    Update: Turns out it is a time thing! Audio starts working around 12 seconds after the GAME begins (Notice that this is the exact same amount of time a scene needed for loading). Once it has worked it has worked for the entire game, but in one testing occasion the speech audio refused to play at all. Any idea what is causing it (e.g. being uploaded to memory before it can be played?) and how to fix it?
    Thanks!

  • AC will load in the Asset Bundle as a background process, but it can't assign the files until the whole bundle file has been loaded into memory. This is more of a quirk of the Asset Bundle system.

    I can't tell why one occasion caused no audio to play, but I can look into offering more controls on the scripting side to detect when asset bundles are being loaded in, so that you can implement e.g. restrictions to go past the main menu scene until loading has completed.

  • Sounds great!

  • No problem. I'll be looking to get a bugfix release out next week, so I'll include a new custom event named OnLoadSpeechAssetBundle as well.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.