0
\$\begingroup\$

I am trying to understand why does SceneManager.LoadSceneAsync progress always jumps from 0.0 to 0.9, no matter how big a scene can be.

To try trigger smoother progress of the scene being loaded, I've tried the following:

Generate a large scene from an EditorWindow, containing tens of thousands of objects referencing thousands of assets. Loading this scene didn't produce the intended behavior, rather, it ended up being exactly the same (jumps from 0.0 to 0.9) but with a huge lag at the end since there are many objects.

According this behavior, I am now considering that the supposed asynchronicity in SceneManager.LoadSceneAsync is just about the loading of the scene file itself, not processing its content for being usable by Unity.

Is this correct?

An example on how to load a large scene and report its progress would be appreciated :)

\$\endgroup\$
6
  • \$\begingroup\$ Do your items have lots of components including Awake/OnEnable/Start methods? These can take a substantial amount of time to run after loading/instantiation is complete. \$\endgroup\$
    – DMGregory
    Apr 11, 2019 at 21:17
  • \$\begingroup\$ No, in the test I've done neither of these methods are overridden. \$\endgroup\$
    – aybe
    Apr 12, 2019 at 0:17
  • \$\begingroup\$ AFAIK, it only jumps from 0.9 to 1( you can't get any progress after 0.9). I've used it in my game to show level loading progress and it works fine. Could you show what code you're using for this? It'll help to point out problem, if any. \$\endgroup\$ Apr 12, 2019 at 5:36
  • \$\begingroup\$ You didn't understand my question... \$\endgroup\$
    – aybe
    Apr 12, 2019 at 9:08
  • \$\begingroup\$ Have you tried creating a build and seeing if LoadSceneAsync is actually asynchronous there? I remember having this problem, but only in the editor. \$\endgroup\$
    – Chaosed0
    Apr 12, 2019 at 23:19

1 Answer 1

1
\$\begingroup\$

A while Back CodeMonkey a youtuber has posted a video tutorial for scene manager, there i find this comment from a random guy named Rick Loyd who says

I faced that issue and the only solution I found was to implement loading yourself. Anything you load from code (the way you like to do it), Unity unable to detect and therefor ignores. From my own experiments, the whole loading shows only loading of resources... but neither awake, nor start methods are called until 90%... so basically when you load everything yourself from resources, this code will be executed only after scene gets activated, after 90%. The kind of solution I though is to load resources within loading class and keep them as "do not destroy" until scene you needs gets loaded... however, unity still do not care about that, so you need to give 50% loading to your own code, and 50% to unity loading or make two progress or load progress twice (I have seen such solutions in games too)

Here is the video link

You will find a very good discussion of LoadSceneAsync() in the comment section, check out very first comment pinned by codemonkey.

Lastly Yes this is not a good answer, I know that but I only posted it as an answer because it exceeds the comments allowed letters limit

\$\endgroup\$
3
  • \$\begingroup\$ The guy addresses the first part of it in a very convoluted way! Still, that doesn't answer why it's behaving like that. I guess we've just hit another black box in Unity and we have to roll things out entirely by ourselves ... \$\endgroup\$
    – aybe
    Apr 12, 2019 at 19:19
  • \$\begingroup\$ My guess is that the unity only calculates loading of resources, audio, sprites etc which assigned from the inspector in those 0 to 90 % or 0.0 to 0.9 window, If you are loading anything through the script at the runtime that will not be included in the calculation because Awake() runs after the scene is fully loaded \$\endgroup\$ Apr 13, 2019 at 8:03
  • \$\begingroup\$ In the test I've done there is nothing being loaded from scripts, which makes this even more puzzling. \$\endgroup\$
    – aybe
    Apr 13, 2019 at 9:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .