I updated my project yesterday and I'm not the best at scripting yet, but the upgrade caused me to get an error on line 29 (I added a comment there). I am getting "Type Expected", and "Identifier Expected" both on the same line. But everywhere I look online it seems to be formatted correctly so I'm not sure. This is the entire script btw.
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;
}
}
CodePudding user response:
From .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.
You should remove that line entirely. My guess is something, somewhere, put decompiled code back into the source, where it shouldn't be. You don't need to add that attribute to your code, the compiler will put it for you where it needs to go.
CodePudding user response:
Putting a type in angle brackets as in <NextTrackWait> signifies that it's a passed type for a generic type. However, generic types are used like this GenericType<OtherType> but we can see that you don't have one specified. So that must be where the compiler error is coming from.
Another thing I noticed: NextTrackWait apparently seems to exist in your code as a type and method name. Is that on purpose? Or do you even have a type called NextTrackWait?
