“名称'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语句中输入了源,而不是源(在这里声明:AudioSource[] source = GetComponents<AudioSource>();)。
您已经声明了source,但是正在使用导致错误的原因。

关于c# - “The name '来源' does not exist in the current context [Assembly-CSharp]”,,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50091649/

10-11 08:52