Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Some of the audio tracks are played in unity editor but not in the build version (windows .exe)

Discussion in 'Audio & Video' started by elfnik, Sep 4, 2021.

  1. elfnik

    elfnik

    Joined:
    Feb 3, 2018
    Posts:
    8
    Hi

    I have very strange problem with playing audio tracks when scene is loaded. So, recently I have added new sound file (i have re-check every setting, file type, etc. Everything is in order with the sound it self) and it has to play at certain place (also everything is in order with the sound trigger as well).

    The strangest thing is that the sound is being played in the game editor and if i build the game as single level. The problem occurs when I build the mainMenu level and from there i try to load the next level - the main game level, then the sound is not being played.

    I use SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1) to load the next level -> where the sound doesnt play.

    To make things even clearer, I have tried to replace to trigger any other sound that I have previously added and every sound is triggered with the same trigger, the thing is that only this sound (or any other new sound i add now) is not being called/triggered if I load the level through main menu -> new game

    What could cause this problem? I have no idea how to solve this, any tips?


    Update (FIX):
    I have found the source of the issue, it was all my mistake, i have a script on an object called "Audio manager" which i set not to be destroyed on loading new level. The mistake was here, why? Well I was using the same audio manager object on "main menu" scene and another copy of the same manager in the main game scene -> I have changed the sound in the main game audio manager scene but i did not do that in the main menu scene.
    So when I was starting new game from main menu, it was transferring to the new scene the same audio manager object without the new sound and therefore it was not playing it because it was not added.

    This topic can be closed.
     
    Last edited: Sep 4, 2021
    cloud02468 likes this.