Audio Source not playing when EventSystem is added

It took me a while to find it, I even had to re-create the scene and I happened to forget the EventSystem but… I am developing a simple 2D app. Push a button and it plays a random sound. This works, super easy. There’s a Button UI element and the OnClick calls my script (which is on an object) and that script plays the audio.

I wanted to add a Pitch slider so the script assigns the audio clip to the AudioSource and I attached the UI Slider’s OnValueChanged to my script. Now I realized I need to add my EventSystem but now my buttons won’t play the Audio!

I have Debug.Log statements right before the Play() call so I know the button callback is working there’s just no audio.
Once I delete the EventSystem, the buttons play the audio just fine but now I can’t use my slider. Ideas?

Using 2018.2

Check with Debug.Log(audioSource.clip) (right before Play) whether the right clip is assigned. You say your slider’s OnValueChanged attaches the audio clip - does changing the value of that slider (at runtime) fix your problem?

Yes, I watch the AudioSource on the object and the clip is getting assigned.

private AudioSource audioSource;

....

IEnumerator PlayClip() {
    // Do stuff

    audioSource.clip = audioClip;
    Debug.Log("Playing Clip");
    audioSource.Play();
    while(audioSource.isPlaying)
        yield return new WaitForSeconds(0.5f);
}

public void ButtonPushed() {
    StartCoroutine(PlayClip());
}

public void ChangePitch(float pitch) {
    audioSource.pitch = pitch
}

@LCStark Here’s what’s really happening. When I push a UI Button, “ButtonPushed” is called and an audio clip is assigned to the audioSource and the audioSource is played.
When I slide a UI Slider is moved the “OnValueChanged()” is triggered to call “ChangePitch”

Now when there is no EventSystem in the Scene I can push the button and the clip will play but I obviously cannot interact with the slider.

When I add an EventSystem then push a button I get no audio but of course I can use the slider. Although when I do push a button, I get the Debug statement just no audio. So the buttons callback is getting triggered, the Coroutine is getting called, there’s just no audio.

I did get some input here c# - AudioSource not playing in Unity3d when EventSystem is in Scene - Stack Overflow
but no further ideas.