Search Unity

Audio AudioSource.Play() lags the second time it is called

Discussion in 'Audio & Video' started by _Keith, Feb 1, 2018.

  1. _Keith

    _Keith

    Joined:
    Nov 7, 2015
    Posts:
    27
    I have a button that calls a script on click to enable (load) a menu.

    The menu loads in about half a second.

    The first line of the script is AudioSource1.Play();

    The first time I click the button, the audio plays immediately with no delay (before the menu is visible).

    Every time after that, the audio clip plays after the menu is loaded (visible).

    I can solve this by replacing the line of code with AudioSource1.PlayOneShot(AudioSource1.clip);

    The audio file is uncompressed .WAV with a half second duration. It is preloaded, (I've tried tweaking every other setting as well).

    Any ideas on what is causing this? It seems like an issue with the Unity Engine.