Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Visual Studio no intellisense (only: project OR package)

Discussion in 'Code Editors & IDEs' started by Noblauch, May 7, 2020.

Thread Status:
Not open for further replies.
  1. Noblauch


    May 23, 2017
    Hi everyone,

    I have a problem, that my Visual Studio won't show me Unity intellisense autocompletion stuff when I'm working on my in-house package. Here is my Project structure:
    As you can see the Scripts folder shows my "normal" scripts and the intellisense is working just fine.
    However the second highlighted folder also contains scripts (from my packages). They are not shown in the VS Project, but they are indeed there and they are opened in the same Visual Studio window.

    These scripts seem to don't know about Unity or its classes. So I can't get coding guidance or class highlight, nothing. I tried a lot already:
    Checking my settings, restarting, opening in different orders and changing the External Tools Preferences:
    I tried messing with the shown checkboxes and tried every combination. The results are interesting:
    If I check the green Button, the intellisense for the "Packages" folder works again, but the overall Unity project loses every reference to my package classes. The namespaces are unknown and everything gets red underlined. If I try to run the code anyway it compiles and runs just fine.

    I have the feeling that I'm so close to the solution, but I'm going back and forth and can't get it to work.
    Hopefully someone has an Idea!
    Last edited: May 9, 2020
  2. Noblauch


    May 23, 2017
    Meanwhile I found out, that my Unity projects consists two solutions in the root directory.
    Every one of these solutions works for its part. The MyPackages.sln works with the project and the com.homemade-studios.utility.sln works for the package.
    I guess I need a combination of the two? But not sure if this is possible. Or how these became two in the first place..
    PraetorBlue likes this.
  3. Noblauch


    May 23, 2017
    Okay, I finally figured it out. Get hold of your pants, I'm going to make your life a better place now:
    For those Unity & VisualStudio veterans, you have to tick "Embedded Packages" in Unity's External Tools preferences and remove and re-add the assembly/project reference to your package in VS.

    (maybe some steps are not required, but lets go through them all, just in case)

    The Problem:
    Visual Studio recognizes the files from your project and your package, but is unable to provide intellisense and / or recognize your package or namespaces inside the unity scripts.

    Step 1:
    Delete your Visual Studio stuff from your Unity project, just kill the project and solution files.

    Step 2:
    Make Unity recreate your solution: Unity –> Preferences –> External Tools and check Embedded packages and keep Editor Attaching checked. Now click on Regenerate project files.

    Step 3:
    Reopen your Solution, by clicking on a unity script or the newly created .sln file in your projects root directory.
    Open the Visual Studio Classes window View –> Pads –> Classes and click on the References folder that belongs to your Unity project. Now go to Project –> Add Reference...

    Step 4:
    In this newly opened Window find your package and wonder why it's ticked but obviously not referenced.
    Under the All tab, uncheck your package and click okay, then go back and re-check your package and hit ok. Your package should also be checked under the Projects tab, but this gets done automatically in my case.
    I guess this is obviously a bug, and don't ask me how I was even able to find this out, indeed it took me two days.

    Step 5:
    Profit. Your package and namespaces should nor work inside the unity scripts and all of the files should have intellisense and know about Unity's classes!
  4. NicolasCEMU


    Sep 8, 2017
    It worked, thank you.
    Noblauch likes this.
Thread Status:
Not open for further replies.