Search Unity

Visual Studio's intellisense won't accept UnityEngine namespace

Discussion in 'Scripting' started by FeastSC2, May 2, 2018.

  1. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    2 days ago my Visual Studio's intellisense started to not being able to recognize the using UnityEngine; namespace. My game can run, so the scripts compile and there's no real error but Visual Studio doesn't understand that. What can I do to try and fix this intellisense problem?

    upload_2018-5-2_20-44-34.png
     
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,188
    zhiligeng likes this.
  3. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
  4. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,188
    It's not just about new scripts. It can effect all scripts. No way to know if this fix works for you if you don't try it. :)

    Not saying it will fix it. But it sounds very similar.
     
  5. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    I tried it but it didn't work out, I chose to reinstall after all and now that it's just finished everything seems to be in working order again. Thanks for trying to help out @Brathnann!
     
  6. FrankL2

    FrankL2

    Joined:
    Sep 24, 2019
    Posts:
    1
    I found the answer. UnityEngine namespace targets .NET Framework 4.7.1. After downloading from [https://dotnet.microsoft.com/download/thank-you/net471-developer-pack] and installation, I now have working intellisense.
     
    OllieVentures likes this.
  7. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    981
    Also, just to add. If your Visual Studio can't find any references to UnityEngine objects, like GameObject, or Application classes, then it's also likely Visual Studio doesn't have your current Unity project opened.

    When you start Unity, and load up your scene, but you have not open Visual Studio yet, don't just jump straight to opening a C# script inside Unity editor. That will only open up the C# script inside Visual Studio, and it doesn't open the Unity Visual Studio project at all.

    I'm not sure of any better ways to open Visual Studio projects through Unity editor. The only known solution I have is to open the VSPROJ file or the SLN file from your Unity project root directory. It's not like Unreal Engine 4 where you have the option to generate a Visual Studio project, nor is it like Unreal Engine 4 where by double-clicking on the C++ script, UE4 will automatically open the Visual Studio project and open the selected file.

    Hello,

    Which of the .NET Framework 4.7.1 I need to install? I would prefer not to download standalone developer packs, and would rather go through the Visual Studio installer and have it install 4.7.1 instead, so that it can integrate better with Visual Studio, and let me uninstall 4.7.1 if needed.



    Is it the .NET Framework 4.7.1 SDK, or the "targeting pack"? I'm assuming it's the latter, as it sounds like it's a "Developer Pack" thing.
     
    Last edited: Oct 13, 2019
  8. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,188
    Double clicking a script in Unity opens the project as well, considering it's exactly how I do it all the time. Also, if you don't have the proj files, the first time you open a script, it will create them for you. This may be tied to the Unity VS tools, but honestly, I can't recall this ever not being the case.
     
  9. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    981
    It's no longer doing this for me in Visual Studio 2019 Community. I have to manually open the SLN solution file located in the Unity root project directory, in order for VS 2019 Community to open the Unity project up.
     
  10. Mark2W

    Mark2W

    Joined:
    Jul 24, 2018
    Posts:
    1
    I was helped by deleting the ".vs" folder and the "<project name>.sln" file from the project root folder.
    Then I open my project in Unity again and double-clicked on the script from the Unity Editor
     
    anastasiavtes likes this.
  11. anastasiavtes

    anastasiavtes

    Joined:
    Aug 1, 2020
    Posts:
    1
    Your solution worked for me, thanks!