- Home /
Any way to disable log message "There are no audio listeners..."?
So, as the title says, I want to stop seeing a Console log that looks like this:
There are no audio listeners in the scene. Please ensure there is always one audio...
There are no audio listeners in the scene. Please ensure there is always one audio...
There are no audio listeners in the scene. Please ensure there is always one audio...
There are no audio listeners in the scene. Please ensure there is always one audio...
But, I also want to be able to playtest my game in the editor without hearing sound effects, because I hear them looping for hours on end every day. Also, I want to stream music whilst I code, and being forced to listen to my SFX at the same time is irritating.
I can think of a bunch of sub-optimal solutions which either require changing my project structure or externally disabling sound in my OS, but what I really want to know is...
Is there actually a setting somewhere to turn this off, or at least stop it from printing every single frame?
Just checking. Have you tried the obvious of hitting the "Mute" button in game view?
Answer by OncaLupe · Dec 17, 2015 at 05:02 AM
Not sure if you can disable that warning, but you can mute Unity in a few ways:
Edit > Project Settings > Audio > Disable Unity Audio (at least for Unity 5.3, never checked for this before).
Have all your audio run through an Audio Mixer and mute the main channel and/or use manual variable volume control. (Not a bad idea anyway to give players ability to adjust volumes).
If you're using Windows, you can use the volume mixer to mute Unity when you need (Likely on a Mac as well but I've never used one). If you have the volume control shown in the system tray (looks like a speaker next to the clock, normally bottom right, may need to click the chevron/arrow to expand hidden icons), right click it and choose Open Volume Mixer. Find Unity in the list of programs (or if you're testing a build, whatever you named your game) and click the speaker icon under the slider to mute just it.
It's very cool that the "Disable Unity Audio" option exists. I never knew we had that (maybe like you said it's a newer option), and it's easily the quickest way to mute Unity, from within Unity, and avoid those messages. Thanks!
Answer by felixfors · Dec 18, 2015 at 07:28 PM
There is a " Mute audio" button at the top right corner of the game window. No need to turn off any components or change the project settings.
Of course it does fix the actual problem and not the problem that was introduced by the wrong workaround (i.e. the removal of the AudioListener component).
You always need exactly one AudioListener in your scene. If you have one, the error / warning is gone.
Answer by pointcache · Jan 22, 2017 at 08:35 PM
Ok i managed to mitigate the "no audio listeners" useless errors with this
using UnityEngine;
using UnityEngine.UI;
using System;
using System.Collections.Generic;
/// <summary>
/// USAGE: create top level listener that will be enabled disabled automatically
/// add this script to every listener, and mark top listener as default mode
/// </summary>
public class AudioListenerController : MonoBehaviour {
public Mode mode;
/// <summary>
/// Scene is the on on camera, default is the one that will substitute the missing
/// </summary>
public enum Mode {
sceneListener,
defaultListener
}
static AudioListener current;
AudioListener listener;
private void OnEnable() {
listener = GetComponent<AudioListener>();
if (mode == Mode.sceneListener)
current = listener;
set();
}
private void OnDisable() {
if (mode == Mode.sceneListener) {
if(current == listener)
current = null;
}
}
void set() {
if(mode == Mode.defaultListener) {
listener.enabled = current == null;
}
}
private void Update() {
set();
}
}
However the stupidity of this comes from the fact that its the editor itself that fires those errors, not the engine, as a result it will just dump them all over the place even when game is on pause, as usual gloriously smart decision making.
Answer by sniperisa · Jan 22, 2017 at 08:11 AM
Why can that notice not deactivated? My game can be loaded as a dedicated server and i don't want it to play sounds then. If you run it as client it's fine, the client has an audio listener and plays the sounds but when it is run as a dedidcated server that notice will probably use resources it doesn't need to. And i don't want to deactivate every sound source in case the game is run in server-mode...
Answer by jimmycrazyskills · Dec 16, 2015 at 09:06 PM
Could you just add a audio listener, but create a script that temporarily disables all audio sources(for each through them)?