"Unity.InputSystem does not contain a definition for SaveAndReset"

This error suddenly started appearing when I build my unity solution in visual studio. It’s not an error in Unity, just in VS 2022, and it’s preventing me from attaching the debugger because the build is failing. I build, and I see these errors.

And I go there in the script, and that line is in fact erroring out, but only in VS, not unity console. And since it’s a default unity package, I can’t (aren’t supposed to) edit the lines, so I can’t remove the error.

What’s the cause of this and how do I fix it?

This may help you with intellisense and possibly other Visual Studio integration problems:

Sometimes the fix is as simple as doing Assets → Open C# Project from Unity. Other times it requires more.

Other times it requires you also nuke the userprefs and .vsconfig and other crufty low-value high-hassle files that Visual Studio tends to slowly damage over time, then try the above trick.

Barring all that, move on to other ideas:

https://discussions.unity.com/t/778503

Also, try update the VSCode package inside of Unity: Window → Package Manager → Search for Visual Studio Code Editor → Press the Update button

Also, this: https://discussions.unity.com/t/805330/7

2 Likes

None of these work, I don’t think this is a VS issue but a project issue. Multiple people are working on this project, not a single one of them is able to get the debugger to work anymore.

It’s like scripts in certain assemblies can’t be attached to

I was having the exact same issue. This fix worked for me: Close Visual Studio, then in Unity under File → Build Settings, check the Development Build box, then under Assets click “Open C# Project”.

Hope this helps!

3 Likes

I’ve always had that checked so it is not the case. However, another thread says VS2022 17.6 is meant to fix this issue so hopefully that will do it.

I was running into this issue and @gogman 's solution worked for me. (Unity version 2021.3.25f1, VisualStudio Version 16.11.13) Thank you!

This also worked for me. Thanks.