I have installed the new InputSystem package in my Unity project. I have set the input to "new inputsystem" in the Unity Player Settings. I have quit and restarted both Unity and VS Code.
But when I try to use the system in VS Code, I immediately get this error:
using UnityEngine;
using System.Collections;
using UnityEngine.InputSystem; // <-error
using UnityEngine.InputSystem.Controls; // <-error
The type or namespace name 'InputSystem' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?) [Assembly-CSharp]
What can I do to make VS Code recognise the Unity InputSystem package?
Why do I get a "Advertisements" does not exist in the namespace "UnityEngine" error"? This error is typically caused by one of two issues: You are building for a platform that is not supported by Unity Ads. You have not imported the Unity Ads package into your project yet.
The type or namespace name 'InputSystem' does not exist in the namespace 'UnityEngine'. Unity compiles the script just fine and it works correctly, so the issue is something with the Unity/Visual Studio interaction. I'm using Unity 2021.2.8f1 and Visual Studio Code 2021 1.63.2.
However, any reference to namespece UnityEngine.InputSystem got errors. What I found that Unity.InputSystem.dll didn't exist under [Project Dir]/Library/ScriptAssemblies/Unity.InputSystem.dll, which is what the Unity project refers to. This path can be found in Assembly-CSharp.csproj, placed right under Unity project directory.
Visual Studio Code is not recognizing the InputSystem namespace on the line The type or namespace name 'InputSystem' does not exist in the namespace 'UnityEngine'. Unity compiles the script just fine and it works correctly, so the issue is something with the Unity/Visual Studio interaction.
I have also noticed that UnityEngine.EventSystems is not listed in the current API, but it is in the 2018.2 API. I know this is a year old but just to clarify steps if anyone else encounters this issue (as it's just taken me some time to figure it out).
The issue is that the required .csproj files (VSCode needs them to understand the available libraries) for the new package were not auto-generated when you installed the new package (it didn't happen for me either, maybe it is intentionally manual).
Go to Edit -> Preferences...
and then click on External Tools
. You need to tick the box to Generate .csproj files for:
Registry packages
(and any other ones you might want) and then click on Regenerate project files
.
That should generate whatever is needed for VSCode to recognize the new package - you shouldn't even need to restart it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With