-1

I am following this tutorial on Youtube to begin my first ever Unity/C# project. However, I am stuck at about the 15 minute mark, where he uses

    Invoke(nameof(ReloadLevel(), 1.3f));

at which point VSCode and Unity both object because "The name 'nameof' does not exist in the current context [Assembly-CSharp]"

Googling the issue shows this user and this user both being advised to update their programs, but mine are all freshly installed, so I'm not sure what the issue is. I am using VSCode 1.74.2, Unity 2021.3.16f1, and have the C# extension by Microsoft, v1.25.2. I have omnisharp.useModernNet set to false (the issue persists regardless of this being true or false, it seems), and .Net Framework 7.0.10 installed, alongside 4.7.1 .Net Dev Pack, as per the C# plugin instructions.

So far I have attempted to regenerate my "Assembly-CSharp.csproj" in case it was just somehow missing.

However, this hasn't worked. Uninstalling and reinstalling .Net with VSCode closed doesn't seem to have fixed it, either.

My expectation is that something just didn't generate properly - OR that the tutorial I'm following is too outdated (1 year), and there's a better way to call this method now. However, I am not sure how to google for that particular solution. Any help would be appreciated.

Rufus L
  • 36,127
  • 5
  • 30
  • 43
  • 3
    `nameof(ReloadLevel(), 1.3f)` is not a valid expression and also not what is done in the video. The video clearly uses `nameof(ReloadLevel), 1.3f` - which is very different – UnholySheep Dec 21 '22 at 00:18
  • I had a suspicion it was something incredibly silly, but I couldn't figure out what - I guess my eyes need a break. This indeed was the issue. Can you tell me whether I should leave this question up (in case future googlers need a reminder to check their syntax) or remove it (because it's a non-issue)? – Katu Monsterpants Dec 21 '22 at 00:23

1 Answers1

1

It's because of parantheses. You should write

Invoke(nameof(ReloadLevel), 1.3f);

Hope this helps.