Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

The type or namespace name "Cinemachine" could not be found

Discussion in 'Scripting' started by OriolEscolar, Apr 25, 2020.

  1. OriolEscolar

    OriolEscolar

    Joined:
    Dec 19, 2017
    Posts:
    5
    Hi!

    I'm using Unity 2019.3.7f1 and VScode as my IDE. I have downloaded Cinemachine via Package Manager but when I try to use Cinemachine in one of my scripts I get the following error:

    Code (CSharp):
    1. using Cinemachine;
    Code (CSharp):
    1. The type or namespace name 'Cinemachine' could not be found (are you missing a using directive or an assembly reference?) [Assembly-CSharp]csharp(CS0246)
    Thank you in advance!
     
  2. Carwashh

    Carwashh

    Joined:
    Jul 28, 2012
    Posts:
    746
    You've probably got another compile error you need to fix first.
     
  3. OriolEscolar

    OriolEscolar

    Joined:
    Dec 19, 2017
    Posts:
    5
    I have no errors in Unity, the only issue is I can't use Cinemachine.
     
  4. URekt

    URekt

    Joined:
    May 2, 2017
    Posts:
    5
    I have the same issue using Rider, I've tried deleting all the .sln and .csproj files but nothing helps any ideas?

    Also tried removing and adding Cinemachine from the package manager.

    There are no Compile errors and if I start a brand new project everything works
     
    Last edited: Jul 16, 2020
  5. herra_lehtiniemi

    herra_lehtiniemi

    Joined:
    Feb 12, 2017
    Posts:
    133
    I also have the same - Visual Studio Code gives errors. However, in Unity it works so I can still use it. VS Code underlines it as red. Usually with something like this, recreating project files from Unity settings helps. If this doesn't help, you can close Unity and delete the Library folder inside Unity. This will cause a full reimport, but might help. In general, I find VS Code loses the connection to Unity a LOT (debugger doesn't always connect, I get similar errors as you, so there's most definitely a lot to improve there). Resetting solutions often helps, closing VS Code and Unity and starting Unity fresh.
     
    hanscity likes this.
  6. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,971
    As others note, based on the above description, this is almost certainly just an Intellisense issue.

    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.

    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