Search Unity

Input System - The type or namespace name 'InputSystem' does not exist in the namespace UnityEngine

Discussion in 'Editor & General Support' started by kless135, Jan 17, 2022.

  1. kless135

    kless135

    Joined:
    Jan 17, 2022
    Posts:
    2
    I've just installed the Input System Package in Unity. Visual Studio Code is not recognizing the InputSystem namespace on the line
    using UnityEngine.InputSystem;
    reporting that:
     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.

    I've tried everything suggested in this thread, including:
    * Installed the Input System in Unity by going to Package Manager -> Input System -> Install.
    * After installing, clicked 'yes' on the popup to use the new system instead of the legacy system. I confirmed this by going to Project Settings -> Player -> Configuration -> Active Input Handling and confirming that Input System Package (New) is selected.
    * Regenerated project files by going to Preferences -> External Tools -> checking all boxes and clicking Regenerate project files. I also made sure that the External Script Editor is chosen as Visual Studio Code.
    * Confirmed that the Visual Studio Code Editor package is installed in Unity.
    * Deleted the project's Library folder.
    * Deleted the project's .csproj files in the project's root directory.
    * Restarted Unity and Visual Studio Code.
    * Restarted my computer.
     
    Starpest likes this.
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,726
    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://forum.unity.com/threads/intellisense-not-working-with-visual-studio-fix.836599/

    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://forum.unity.com/threads/no-suggestions-in-vscode.955197/#post-6227874
     
  3. kless135

    kless135

    Joined:
    Jan 17, 2022
    Posts:
    2
    Thanks for your response!

    I gave this a try, with no luck.

    Could you tell me where I might find these files?

    I tried this previously and it didn't seem to make any difference for me.

    I have this package installed but there isn't any update button that I see, only remove. Does that mean it's up to date? I have version 1.2.4.
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,726
    They should all be right in your project root, all the Microsoft barf you don't need to source control. I think the entire .vs directory, .vsconfig, .userprefs, .sln, .csproj, just destroy it all, then let Unity recreate.

    Barring that it's gonna be the standard Visual Studio troubleshooting: uninstall and reinstall until it finally starts working. The fact that it works in Unity proves you have the actual class, now you just have to convince Visual Studio of this.
     
  5. Starpest

    Starpest

    Joined:
    Jan 13, 2022
    Posts:
    1
    Bumping to say I have the same issue. I've managed to get rid of the error in VScode so I can keep working on my project, but am unsure if it is a solution.. Anyway here's what I did to get rid of the red squigglies:

    +Delete the .sln and all .csproj files in your project
    +Close Code
    +Create a new Assembly Definition in Unity

    +Select Unity.InputSystem under Assembly Definition References, and tick Override References at the top

    +In Unity Preferences (Edit > Preferences) DO NOT tick the .csproj generation boxes for Registry packages
    +Generate the other packages you need, and voila no more squigglies and screeching from Code

    Like I said before, this is not a solution and you will probably miss out on some intellisense for InputSystem but at least you can keep your sanity until the IDE or Unity's interactions with it get updated.