"在当前上下文中不存在名称'sources'[Assembly-CSharp]",
帮助!(统一 2017.3.0f3(
代码如下:
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)
{
}
}
你在 foreach 语句中键入了 sources,而不是 source(在这里声明:AudioSource[] source = GetComponents<AudioSource>();
(。 您已声明源,但使用的源是导致错误的源。