gpt4 book ai didi

c# - “The name '来源' does not exist in the current context [Assembly-CSharp]”,

转载 作者:行者123 更新时间:2023-12-02 23:32:53 25 4
gpt4 key购买 nike

“名称'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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com