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

Audio Streaming Assets for audio

Discussion in 'Audio & Video' started by c2_unity_1, Dec 17, 2019.

  1. c2_unity_1

    c2_unity_1

    Joined:
    Dec 4, 2019
    Posts:
    2
    Hey everyone, trying to use streaming assets to pull in audio that can be swapped out later and running into an issue that I don't understand.

    The first time my PlayBrief function runs it'll successfully find the wav and send it as a clip to PlayAudio and I'll hear it. However, it fails to find any other audio files and it won't even play the first one a second time. I know PlayBrief and PlayAudio are triggering multiple times cause I'll get the message about trying to find the file and also had a print inside of play audio that would trigger every time. The audio just never seems to get updated or replayed.

    Am I missing a setting or is something else happening that I don't get? I am not getting any errors that I can see.
    //////////////////////////////////////
    void PlayAudio(AudioClip audioClip)
    {
    if(!_AudioSource.isActiveAndEnabled)
    {
    _AudioSource.enabled = true;
    }

    _AudioSource.Stop();
    _AudioSource.clip = audioClip;
    _AudioSource.Play();
    }

    void PlayBrief()
    {
    print("going to try to find " + vignette.Name + "_brief");
    string path = Path.Combine(Application.streamingAssetsPath, "" + vignette.Name + "_brief.wav");

    WWW www = new WWW(path);
    AudioClip clip = www.GetAudioClip();

    PlayAudio(clip);
    }
    ////////////////////////////////////////////////

    Thank if anyone is able to help.