1

"The name 'sources' does not exist in the current context [Assembly-CSharp]",

Help! (unity 2017.3.0f3)

Here's the code:

public static SoundManager Instance = null;

public AudioClip goalBloop;
public AudioClip lossBuzz;
public AudioClip hitPaddleBloop;
public AudioClip winSound;
public AudioClip wallBloop;

private AudioSource soundEffectAudio;

// Use this for initialization
void Start () {

    if(Instance == null)
    {
        Instance = this;
    } else if (Instance != this)
    {
        Destroy(gameObject);
    }

    AudioSource[] source = GetComponents<AudioSource>();

    foreach(AudioSource source in sources)
    {

    }

}
MSDN.WhiteKnight
  • 664
  • 7
  • 30

1 Answers1

0

You have typed sources in foreach statement , instead of source (declared here: AudioSource[] source = GetComponents<AudioSource>();). You have declared source but are using sources that is the cause of the error.

JoelC
  • 3,664
  • 9
  • 33
  • 38
ARS1337
  • 1
  • 1
  • 2