LoadSceneAsync, LoadScene and Resources.UnloadUnusedAssets

When I load my scene using loadsceneasync, the loaded scene becomes very laggy on my S4. Fps is around 25 - 33. But when I load my scene with loadscene. Fps is quite high, in the 41 - 50 fps region. I thought it could be something to do with memory usage, So I called Resources.UnloadUnusedassets() on scripts that might be storing memory but its still not working.
I would have called Resources.UnloadUnusedassets() on all scripts but I fear it might crash my scene. So I avoid that. I would like to know your practice for calling Resources.UnloadUnusedassets().
If you also know what might be causing the problem of low fps when using loadlevelasync and no drops when using loadscene, please do tell me.

Is it only temporarily laggy? Are you watching the AsyncOperation that’s returned from your LoadSceneAsync method to make sure the loading is complete? It’s possible that the scene loading is not even complete yet.

What happens is, I have an intro scene where the loadlevelasync is called for the next scene but the isallowedtoloadlevel is set to false. When the player presses the start button isallowedtoloadlevel is set to true and the next level is loaded. In that level I am facing fps issues.

Would it be possible instead, using LoadSceneAsync and getting the AsyncOperation, to then set the allowSceneActivation property to false? Then when the user clicks the button, toggle that to True.

See if that makes a difference. It should accomplish pretty much the same thing, except using the newer SceneManager bits.

I must apologise. Instead of isallowedtoloadlevel I should have said allowsceneactivation. That is how I am doing it. Referring the AsyncOperation and then accessing the allowsceneactivation variable. Once the player presses the start button I set allowSceneActivation to true.

Excuse me, using my mobile so had to define those words from the top of my head.

No problem. I’m not sure… Are there streaming assets like asset bundles that might still be loading? The way you’re doing it, isDone will never be true… but once the progress hits 0.9 it should be done, at which point toggling that flag shouldn’t be causing lag spikes.

How do I check for streaming assets like asset bundles?

You probably don’t have them then. :slight_smile:

Ugh…I get the feeling I have to through long frustrating nights again! :smile:

1 Like

Sorry I couldn’t be of any help.

I don’t think you’re removing your intro assets. When you load async, it does not get rid of anything. So likely, that’s still rendering/playing in the background?

1 Like

Oh no buddy! Really appreciate your assistance!

I checked the hierarchy tab, there is nothing from the previous scene once it loads. Unless, they remain in the memory. Should I try and blast that scene with Resources.unloadunusedassets in the scripts.:smile:

1 Like