"There are no audio listeners in the scene." That's actually fine, right?

I keep getting this message in the log:

It happens when I do loading between modes that have different camera/audio listener setups.

This is fine, right?
The message is just a bit annoying, that’s all.
How is one supposed to manage always having one audio listener, and not 2, and not 0?

1 Like

It’s 100% fine. It’s notifying you because it’s a newbie mistake and confusing if no sound is playing. Usually if you make a Unity camera, it will contain a listener. In your case you have either not got a camera in this scene, or have removed the listener. It won’t break anything (except sound).

If you have a listener by the time you need to play a sound, all will be well. If you want a persistent listener, simply use Unity - Scripting API: Object.DontDestroyOnLoad

1 Like

Hey, @hippocoder . Long time no see. (Pharan from the Spine forums)

The message was just annoying is all. It wasn’t actually causing me any problems.

Again, I had different camera/listener setups (static, follows the character in game mode, etc…). So just marking it as DontDestroyOnLoad isn’t a complete solution.

I guess what one could do in that case is make a script that manages which Transform it should attach itself to, and have each kind of camera mode grab and release that AudioListener’s Transform when it starts or ends.

Yep, just have it decoupled somehow, if you need the audio to be persistent (ie playing music throughout).

  • [quote=“hippocoder, post:4, topic: 615821, username:hippocoder”]
    Yep, just have it decoupled somehow, if you need the audio to be persistent (ie playing music throughout).
    [/quote]

I know it’s kind of an old thread.

But do you know if there is a way to suppress those messages, Because it appears every frame and If I want to use Debug.Log(“something”) it will appear for one frame and then continue on spamming me with those messages…

So my question is, is there a way to write something in script to intentionally not show that message?

Edit: And of course I’m not looking for an answer like “turn it on” I’m intentionally turning it off by a press of a button as a Stop music button mid game. I know I could just make that button turn off the background music but Still would like to know if there’s a way.

3 Likes

Yep same question. In my case I am loading a new scene asynchronously so the player gets unloaded, I start loading the scene and a new player gets created when the scene is done. And all the while it is spamming this message telling me there are no audio listeners. Really would like a way to not bloat my logs with that. Makes debugging real issues more difficult.

5 Likes

Check my camera, check enable audio listener or add audio listener.
2 audio listener in scene eror, disable no used audio listner.

The same issue bothers me too …

yes where can I disable the No audio listeners in the scene log message. Its super annoying

1 Like

Add an AudioListener in your scenes and it should stop complaining. Unfortunately, I don’t know any way to suppress log messages.

by Adding an fixed AudioListener cause the problem that have 2 audio listener in scene when the player character(and the camera) spammed by the server…
I realy want to deactivate this message, horrible to debug the game…

It depends on your need and how to know which one is needed. For example, this script removes any AudioListener from GameObject that doesn’t have the specified name.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RemoveDuplicateAudioListener : MonoBehaviour
{
    public string gameObjectName = "";

    private void Awake()
    {
        AudioListener[] listener = FindObjectsOfType<AudioListener>();
        for (int i = 0; i < listener.Length; i++)
        {
            if(listener[i].name != gameObjectName)
                Destroy(listener[i]);
        }

        Destroy(this);
    }
}

Or you can have a script that check if there is already another AudioListener and remove the one on this GameObject.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RemoveDuplicateAudioListener : MonoBehaviour
{
    private void Awake()
    {
        AudioListener[] listener = FindObjectsOfType<AudioListener>();
        if(listener.Length > 1)
        {
             Destroy(GetComponent<AudioListener>());
        }
        Destroy(this);
    }
}
1 Like

You could try using “Collapse” in the console window.
It wont stop the message but it makes it so that it only takes up a singe line in your window.
It’s not really a fix, more of a workflow workaround.

But it should solve your immediate problem.

This is lame.

My workaround was to set the volume to zero instead of disabling the audiolistener.

AudioListener.volume = enablePause ? 0f : 1f;
2 Likes

My workaround for loading new scene:

GameObject tmp = new GameObject("TemporaryAudioListener");
tmp.AddComponent<AudioListener>(); 
// ... (load next scene async, no additive)```

The Audio Listener acts as a microphone-like device. It receives input from any given Audio Source in the scene and plays sounds through the computer speakers app. For most applications it makes the most sense to attach the listener to the Main Camera.