Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Two audio listeners warning

Discussion in 'Scripting' started by BourneID, Feb 25, 2010.

  1. BourneID

    BourneID

    Joined:
    Feb 25, 2010
    Posts:
    24
    I add two cameras into a scene.As each audio listener has a audio listener.So, I add two audio listeners in the scene.The Unity IDE console always gives me the following warnings:
    "There are 2 audio listeners in the scene. Please ensure there is always exactly one audio listener in the scene.
    "
    Why?How to solve it?
     
    yashgoel8192 likes this.
  2. GargerathSunman

    GargerathSunman

    Joined:
    May 1, 2008
    Posts:
    1,571
    Remove one of the audio listener components.
     
  3. BourneID

    BourneID

    Joined:
    Feb 25, 2010
    Posts:
    24
    I put two cameras in order to switch cameras when playing.So,when switching cameras,should I switch audio listener at the same time?
     
  4. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    You can turn off one of the listeners at a time using the enabled property.
     
    AAAAAAAAAE likes this.
  5. BourneID

    BourneID

    Joined:
    Feb 25, 2010
    Posts:
    24
    Thanks! :D
     
  6. JulieKing

    JulieKing

    Joined:
    Feb 12, 2014
    Posts:
    26
    where do you find the enabled property to remove it
     
  7. Alf203

    Alf203

    Joined:
    Dec 7, 2012
    Posts:
    461
    Its right here in the scripting docs:

    Enabled

    To turn it off in your script, you could do something like:

    Code (csharp):
    1. Camera.GetComponent(AudioListener).enabled = false;
     
  8. JulieKing

    JulieKing

    Joined:
    Feb 12, 2014
    Posts:
    26
    Thanks Alf203 that helped!
     
  9. 123fendas

    123fendas

    Joined:
    May 23, 2015
    Posts:
    44
    I think it'd be
    Code (CSharp):
    1. Camera.GetComponent<AudioListener>.enabled = false;
    nowadays. But this didn't help me, though. I don't have any audio listeners, and I definitely don't have them attached to a camera.
     
  10. Deleted User

    Deleted User

    Guest

    Well it doesn't matter you can use GetComponent with a type instead and that's actually probably more efficient since the generic version casts the Component as the desired generic type while GetComponent(Type) doesn't.

    If you're getting the error, it means you have some Audio Listeners in your scene. Try to browse through the hierarchy to find them.
     
  11. Bigmancozmo

    Bigmancozmo

    Joined:
    Sep 13, 2020
    Posts:
    17
    ahhhhh i figured it out if you have 2 different scenes (i have a player AND menu scene) just disable audio listener on all but one of the scenes you have enabled
     
  12. Calaxe11

    Calaxe11

    Joined:
    Jan 24, 2021
    Posts:
    1
    i'm trying to make a survival game (i'm new btw) and i make import two packages one being the standard unity assets and the other being a texture pack then add a terrian to make my island and then it says i have two audio listeners and now my sound in the game is gone how do i fix this?
     
  13. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,755
    First, please don't reply to 11-year-old posts. Start your own... it's free.

    Second of all, it's a pretty straightforward error. You managed to get 2 audiolisteners into your scene at once. Fix that by removing one of them. If it happens again, figure out how.

    Beyond that, please start your own fresh thread.

    How to report your problem productively in the Unity3D forums:

    http://plbm.com/?p=220

    How to understand errors in general:

    https://forum.unity.com/threads/ass...3-syntax-error-expected.1039702/#post-6730855

    If you post a code snippet, ALWAYS USE CODE TAGS:

    How to use code tags: https://forum.unity.com/threads/using-code-tags-properly.143875/