更新我的项目后,我不断收到 Identifier expected 和 Type expected errors in this script。错误都在第29行

After updating my project, I keep getting Identifier expected and Type expected errors in this script. The Errors are all on Line 29

我昨天更新了我的项目,我还不是最擅长编写脚本的,但是升级导致我在第 29 行出现错误(我在那里添加了评论)。

我在同一行收到“预期类型”和“预期标识符”。但是我在网上看的所有地方似乎都格式正确所以我不确定。

顺便说一句,这是整个脚本。

using System.Collections;
using System.Runtime.CompilerServices;
using UnityEngine;

public class MusicPlayer : MonoBehaviour
{
    public AudioClip[] tracks;

    public float volume;

    public float nextTrackDelay;

    private AudioSource _source;

    private Coroutine _nextTrackCoroutine;

    private void Awake()
    {
    }

    private void Start()
    {
    }

    private void OnDestroy()
    {
    }

    [IteratorStateMachine(typeof(<NextTrackWait>d__8))] //Errors Are Here
    private IEnumerator NextTrackWait()
    {
        return null;
    }
}

来自.NET's documentation

You shouldn't apply the IteratorStateMachine attribute to methods in your code. For methods in Visual Basic that have the Iterator modifier, the compiler will apply the IteratorStateMachine attribute in the IL that it emits.

您应该完全删除该行。我的猜测是某处某处将反编译代码放回源代码中,这是不应该的。您不需要将该属性添加到您的代码中,编译器会为您把它放在需要去的地方。