Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unity type or namespace name 'InputSystem' does not exist in the namespace 'UnityEngine'

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?

like image 855
Kokodoko Avatar asked Aug 28 '20 15:08

Kokodoko


People also ask

Does not exist in the namespace UnityEngine?

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.

Why can't I use inputsystem in unityengine?

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.

Where to find namespece unityengine inputsystem DLL?

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.

Why is Visual Studio not recognizing the inputsystem namespace on the line?

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.

Is unityengine eventsystems listed in the current API?

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).


1 Answers

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.

Screenshot from Unity's Preferences dialog

That should generate whatever is needed for VSCode to recognize the new package - you shouldn't even need to restart it.

like image 106
anula Avatar answered Sep 22 '22 03:09

anula