Search Unity

Question Audio clips stay in memory when switching scenes

Discussion in 'Audio & Video' started by Hermonirr, Jun 1, 2020.

  1. Hermonirr

    Hermonirr

    Joined:
    Dec 23, 2013
    Posts:
    56
    Hi,

    I have one menu scene and three "game" scenes. Each of the game scenes has six long (1-2 minutes) audio clips that may be played simultaneously and replaced with other similar audio clips.
    In addition, dozens of shorter (5 sec) audio clips may be played at the same time.

    When I create a build with just one game scene, it runs fine. In a build with all three scenes I get different results. The first scene loads fine, but the second one does not work well.

    I know it has to do with memory issues. I tried GC.Collect() and Resources.UnloadUnusedAssets when moving from scene to scene, but it seems the audio clips are not unloaded and still occupy memory space.

    What can I do to remove all traces of an unloaded scene?

    Thanks.