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. Dismiss Notice

Visual Studio isn't recognizing my other classes.

Discussion in 'Code Editors & IDEs' started by amitbu, Jun 2, 2019.

  1. amitbu

    amitbu

    Joined:
    May 16, 2019
    Posts:
    12
    Visual Studio isn't recognizing my other classes. I can't create a class reference and I just can't access methods inside the other class. I'm stuck , can someone please help me? Also, in the side you can see (needs migration) , what does that mean?
    Capture.PNG
     
  2. GroZZleR

    GroZZleR

    Joined:
    Feb 1, 2015
    Posts:
    3,201
    Did you update your Visual Studio version to something that breaks the VS Tools for Unity extension?
     
  3. DonLoquacious

    DonLoquacious

    Joined:
    Feb 24, 2013
    Posts:
    1,667
    When it says "Miscellaneous Files" like that, it usually means VS isn't connected to Unity properly. Close VS, then go into Unity, Edit -> Preferences -> External Script Tools and change the External Script Editor to VS and make sure Editor Attaching is enabled, then double click a script in the Project Files to open it in VS again.
     
  4. amitbu

    amitbu

    Joined:
    May 16, 2019
    Posts:
    12
    Everything is as you said, but still getting the problem.
     
  5. Owen-Reynolds

    Owen-Reynolds

    Joined:
    Feb 15, 2012
    Posts:
    1,921
    Googling "unity autocomplete not working" should give the above advice, plus mine: For me I always need to delete every project file: dot-sln, dot-csproj and dot-user. Do it right from the file system. No need to quit Unity. When you go back to the Unity window, it has no problem recreating them, without whatever corruption they had. Back-up your project first (but I've never had a problem). I've found deleting them 1-at-a-time often won't work. It has to be all at once.

    For me, VS Code will stop recognizing anything to do with Unity. It will autocomplete things in the same file, but only how a word processor would - it won't know their types, or be smart enough to list the legal ones only. It can happen twice in the same day, but usually goes weeks without a problem. And it's probably my fault, like switching projects too fast, or forced-shutdowns.
     
  6. KyleSkip

    KyleSkip

    Joined:
    Mar 29, 2020
    Posts:
    1
    Thanks it worked!
     
    jannesyvanen and acgparad0x like this.
  7. Fressno

    Fressno

    Joined:
    Mar 31, 2015
    Posts:
    185
    what worked for me was to in external script tools toggle on and off the Editor Attaching. I also switched between VS and VS code just to force it to understand im using a VS.
     
  8. rohadgal

    rohadgal

    Joined:
    Apr 24, 2021
    Posts:
    1
    Thank you!!! This was really helpful!!!
     
  9. CassClay

    CassClay

    Joined:
    Mar 21, 2020
    Posts:
    20
    In my case I noticed in VS Solution explorer window that additional component had to be installed. I did Installed VS Tools for Unity, however .Net packages for Desktop development also had to be installed. When VS Installer did it's job finally it recognized the Unity classes. Hope it helps!
     
  10. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,762
    Here's my runbook to soothe Visual Studios when it feels anxious at night:

    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
     
    Mikman likes this.