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?
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).
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.
[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.
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.
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);
}
}
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.
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.