2
\$\begingroup\$

The scene I'm working in constantly spams the message There are no audio listeners in the scene. Please ensure there is always one audio listener in the scene. If I add a dummy camera with an Audio Listener, I then get There are 2 audio listeners in the scene. Please ensure there is always exactly one audio listener in the scene.

I know this happens because our camera is created programmatically, with an audio listener. I also realize this will not affect the non-development build in any way.

Is it possible to disable these warnings completely?

\$\endgroup\$
  • \$\begingroup\$ Would you want to add the listener programmatically to the camera at creation? Or you just want to disable the error message? \$\endgroup\$ – user106170 Jan 22 '18 at 15:52
  • \$\begingroup\$ The listener is added programmatically, thus the "There are 2 audio listeners" error when I add a static one. I would like to disable the messages. \$\endgroup\$ – Devil's Advocate Jan 22 '18 at 15:53
  • \$\begingroup\$ you said that the two listeners error comes when you add a listener to the dummy camera. I'm asking if you wanted to add it programmatically to the camera you are adding programmatically, and not have the dummy camera at all. But ok, you just want to disable the error. How will you have sound then? You want to use the dummy camera? That would create a lot of weird problems.... \$\endgroup\$ – user106170 Jan 22 '18 at 15:55
  • \$\begingroup\$ Remove listener from your camera and create prefab from camera then use it \$\endgroup\$ – Seyed Morteza Kamali Jan 22 '18 at 15:56
  • \$\begingroup\$ Sorry guys, I'm new to Unity and I'm just trying to clean up this scene. Our character camera is created programmatically and you CAN hear sounds. I'm only assuming that an Audio Listener is being programmatically attached, thus the "2 listeners" error when I add one statically. Does that clear anything up? \$\endgroup\$ – Devil's Advocate Jan 22 '18 at 15:57
1
\$\begingroup\$

I ended up enabling the Audio Listener on our login camera, then destroying it programmatically when the player camera spawns (this is what was causing the issue).

 staticCamera= GameObject.Find("StaticCamera").GetComponent<Camera>();
 Destroy(staticCamera.GetComponent<AudioListener>());
| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.