Search Unity

Visual Studio not auto-completing Unity components?

Discussion in 'Getting Started' started by 123fendas, Nov 27, 2015.

  1. 123fendas

    123fendas

    Joined:
    May 23, 2015
    Posts:
    44
    Hello. I'm using Visual Studio 2015. I successfully acquainted it with Unity. However, if I type something in that isn't pure C#, a Unity component, it won't auto-complete it. How do I fix this?
     
  2. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,512
    Close Visual Studio, and then from within Unity, select Assets -> [Sync with Project] [Open C# Project] depending on which specific version of Unity you're running. This should open a new VS session (or whichever editor you have configured) with appropriate Unity libraries linked to Intellisense.
     
    Wunizio, srujan1, Terribl3 and 5 others like this.
  3. 123fendas

    123fendas

    Joined:
    May 23, 2015
    Posts:
    44
    Sync with project? I can't find that. Is it because I'm using Visual Studio 2015?
     
  4. 123fendas

    123fendas

    Joined:
    May 23, 2015
    Posts:
    44
    *sigh* I'll have to wait until this Visual Studio thing with Unity works better, because it's confusing as heck.

    I think it's because I downloaded Visual Studio 2015, not 2013, and just... Nobody seems to help me here.

    I'll probably continue with Visual Studio because it looks and works so much better, but if I go crazy I might go back to MonoDevelop.
     
  5. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    There is a copy of Visual Studio that will be auto installed if you select it during the install process.

    When selecting "sync project" or "open project", this is in Unity, not Visual Studio, in the Assets Menu.

    If you are continuing to have issues, and don't need a copy of VS for anything other than Unity, I would try removing VS completely, and then doing an Install of Unity and selecting VS as part ofthe install process.
     
  6. TroubleFox

    TroubleFox

    Joined:
    Feb 28, 2017
    Posts:
    2
    I think i have the same problem here.

    i just started with a clean install of Unity with VS2015.
    I have a Tutorial with a simple HelloWorld-test written in a javaScript which opens VS2015.

    I start to type "Debug" and the intellisense works just like intended until i use the dot and begin with the capital L to find "Log"
    Same goes for "Time.time" but here it doesnt even know "Time" at the beginning.

    This is no big deal, as i can easily write it down. But for the beginning and later on it can get handy to see all the possible functions.

    I am new to JavaScript and would like to have the full list here even when i could go without intellisense.
    So is this already the missing link to the Unity libraries as Schneider21 mentioned?

    Latest Version of Unity does not have "Sync with project". But there is a Refresh in the AssetsTab which doesnt help.
     
  7. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,175
    Visual Studio does not support JavaScript whatsoever. If you want to use JavaScript you have to use Mono Develop instead.

    If you're completely new to JavaScript my advice is to abandon it now before you've wasted too much time and start learning C# instead. Unity's JavaScript has become a trap for new developers. It's barely supported by the community and the official learning resources (there is only one tutorial in the entire collection that actually covers it).
     
    Last edited: Feb 28, 2017
    SarfaraazAlladin and Kiwasi like this.
  8. TroubleFox

    TroubleFox

    Joined:
    Feb 28, 2017
    Posts:
    2
    Thousand thanks for the quick answer.
    It was only part of the tutorial for the "Hello world" part. I plan to use C# for coding.
    Just was wondering, why JavaScript intellisense wasnt working properly and if there is a solution for it.

    When C# works with intellisense as it should everything will be fine.

    Update: after a quick check everything in C# works as intended. It was only the missing JavaScript-Support
     
  9. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,175
    Originally the asset that links Unity and Visual Studio was developed by a company called Syntax Tree. Back in the early days it supported both languages, but Unity's JavaScript support was dropped shortly before Microsoft bought them up.

    By the way the reason I'm referring to it here as Unity's JavaScript is because it isn't actual JavaScript. You can find mention on the web of enabling JavaScript in VS, but it won't help with this situation because it's a different language as far as the IDE is concerned. Mono Develop only has support because Unity has its own modified Mono Develop too.
     
  10. bonez9oh5

    bonez9oh5

    Joined:
    Apr 3, 2017
    Posts:
    3
    have the same issue as above but only on my newest c# script. weird as hell because ive tried closing it down completely ans its not even giving me the prompt to refresh my solution. any way to refresh it manually?
     
  11. bonez9oh5

    bonez9oh5

    Joined:
    Apr 3, 2017
    Posts:
    3
    turns out my new c# file, although created in the unity project, is not associated to my project
     
  12. bonez9oh5

    bonez9oh5

    Joined:
    Apr 3, 2017
    Posts:
    3
    solution to my issue was to go into the visual studios solution and go to Project -> add existing item... then locate the file in the explorer window that opens and select it. it adds the file back into the correct project and enables the unity dependencies.
     
    amoqix, KIra_King and Hiyek like this.
  13. markgrossnickle

    markgrossnickle

    Joined:
    Aug 21, 2017
    Posts:
    32
    This started happening to me after wiping my computer and starting with a fresh install of Unity 2017.2 and Visual Studio 2017.

    Now whenever I create a new class in Unity it will not be recognized in Visual Studio.

    The quickest solution I've found is to find the class in Visual Studio's solution explorer and exclude it from the project. Then toggled on show all files (at the top of the solution explorer) and find the class again. This time right click and include it in the project.

    After that it seems to behave normally.
     
    Jwizard93 and Cndymn like this.
  14. Jwizard93

    Jwizard93

    Joined:
    Feb 23, 2017
    Posts:
    1
    markgrossnickle's solution worked for me with VS 2017. When I followed his steps for one file all of the other problem files were fixed as well. Thanks for the info!
     
  15. Pepis77

    Pepis77

    Joined:
    Mar 25, 2018
    Posts:
    1
    Hey! So this happened to me when I downloaded the latest version of standard assets. What i did was simply putting the standard assets folder inside another folder and VS began working properly again. Idk why that happens
     
  16. MurcsRoyce

    MurcsRoyce

    Joined:
    Jul 19, 2017
    Posts:
    38
    #schneider21 Answered the question. and it works for me. Inside unity click Assets /Open C# Project / in the open window you will see a CSHARP script. open that , it will build your assets into visual studio. Then inside unity open a script, visual studio now works with your unity project. This Thread has been [SOLVED]
     
    LedKarlsson and Marcsairu like this.
  17. Hiyek

    Hiyek

    Joined:
    Nov 28, 2017
    Posts:
    3
    Logged in just to say thank you so much for this solution @bonez9oh5 !! Solved.
     
  18. TropicalBananaFish

    TropicalBananaFish

    Joined:
    Apr 8, 2017
    Posts:
    1
    This does not work for me. Nothing happens when I click that button.
     
  19. MurcsRoyce

    MurcsRoyce

    Joined:
    Jul 19, 2017
    Posts:
    38
    It might be confusing and you might not be doing it right Tropical ! Also If you reinstall Visual studio with Unity option selected it will fix your issue. Clicking Assets , Open Unity C# project , Select the script to open will let visual studio know your working inside unity with these scripts

    Both methods do the same thing.
     
  20. dleight

    dleight

    Joined:
    Jan 28, 2014
    Posts:
    7
    DaizeUK, lycanstein and ghostliquid like this.
  21. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,175
    I'm not surprised. Visual Studio for Mac is a fraud. It's not the real Visual Studio. It's Mono Develop with a name change and some additional functionality thrown in (mostly in the bundled tools department). If you want to fix problems with it you will want to search for solutions to similar problems people have had with Mono Develop.
     
  22. aftasea

    aftasea

    Joined:
    Sep 13, 2012
    Posts:
    5
    I had the same problem on Mac with Unity 2019 and Visual Studio Community. My fix was to go to Assets->Open C# Project.

    I guess it would create the solution if there were any.
     
  23. ImperialDynamics

    ImperialDynamics

    Joined:
    Jun 21, 2018
    Posts:
    21
    i do the same thing as aftasea (I go to Assets>open C# project). Nothing else works
    I'm surprised -and disappointed- that neither Microsoft, nor Unity have still found a solution for this annoying issue!
     
  24. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,175
    Have you reported the issue to Unity and Microsoft? Neither company relies on their forums for bug reports. If they're not already aware of it they won't be made aware of it by posting here.
     
  25. Ghady983

    Ghady983

    Joined:
    Oct 4, 2018
    Posts:
    2
    Guys , for the ones who still have that error, well there is a solution. the problem is that VS needs a .sln file for the project while VS should create one but it couldn't . Whatever, you need to create That Format using VS Code, It Is small and for free. Just Change the script editor in preferences to vs code and open at least 1 script with vs code and change back to VS(The original). Now You're asking why can't VS create Sln, it may be because you accidentally changed something in the settings or somewhere else. That's why Louis's solution worked because When he re-installs it, Everything goes back to default
     
  26. iankitdeshmukh2

    iankitdeshmukh2

    Joined:
    Sep 7, 2019
    Posts:
    1
    Thanks. This worked for me :)
     
  27. Lagermeister

    Lagermeister

    Joined:
    May 13, 2017
    Posts:
    18
    I had the same problem (Unity 2019.2). In "Preferences" scripts were "opened by file extension". In my case it was always VS 2019. Even when i checked that a Projectmap should be created i had still no IntelliSense and a Projectmap was never created. The solution was that instead "open by file extension" i entered the path to Visual Studio ("C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\devenv.exe") and now Unity detected Visual Studio. After reopening the project and a script IntelliSense was available.
     
  28. PumpkinLizard

    PumpkinLizard

    Joined:
    Jan 7, 2020
    Posts:
    1
    worsk for me!
     
    PurpIe and cbanacka like this.
  29. spendooly

    spendooly

    Joined:
    Mar 21, 2018
    Posts:
    1
    This fixed it for me too. Seems things don't work correctly when you do a fresh install of Unity.
     
  30. MikeFParkin

    MikeFParkin

    Joined:
    May 25, 2018
    Posts:
    5
    THANK YOU! This worked perfectly for me
     
  31. Bagellad

    Bagellad

    Joined:
    May 29, 2016
    Posts:
    1
    Thank you, just reinstalled unity and this solved my problem.
     
    Schneider21 likes this.
  32. samedimoo

    samedimoo

    Joined:
    Apr 29, 2020
    Posts:
    1
    for 2019 version of unity follow this video
     
    hmabrok and An0n_Sl0th like this.
  33. Brad-Newman

    Brad-Newman

    Joined:
    Feb 7, 2013
    Posts:
    185
    Solution that worked for me was to:
    1. Quit Visual Studio
    2. Go into the Unity Project Folder
    3. Delete all the .sln and .csproj files
    4. Delete the hidden .vs folder
    5. Unity > Assets > Open C# Project
     
  34. MarvinJesusCalvo

    MarvinJesusCalvo

    Joined:
    May 1, 2020
    Posts:
    1
    Thanks because this answer has helped me with my problem.
     
  35. curmudg3on

    curmudg3on

    Joined:
    May 4, 2020
    Posts:
    1
    I checked and there was no Visual Studio Solution in the Unity Project folder. Visual Studio was just opening the file, which is why Visual Studio was missing references. So, this worked for me:

    1. Close Visual Studio
    2. In Unity, click Edit -> Preferences
    3. Then, click External Tools
    4. Make sure your version of Visual Studio is selected for the External Script Editor
    5. Click on the button, 'Regenerate project files'
    6. Try launching Visual Studio again
     
    Unquerio, JayB975, Noahfense and 6 others like this.
  36. J_S_link

    J_S_link

    Joined:
    May 8, 2020
    Posts:
    3
    I originally down loaded it for c++ I don't know how to change it but it corrects 'Vector3' to 'BitVector32' when I open brackets
     
  37. langexplorer

    langexplorer

    Joined:
    May 25, 2020
    Posts:
    1


    This is exact solution. Thank you very much.
     
    unityvrtest2020 and Dalfamurni like this.
  38. cbanacka

    cbanacka

    Joined:
    Jul 13, 2020
    Posts:
    4
    Worked for me too!

    I was using notepad++ then when i saw how visual studio could do auto complete and all its bells and whistles i changed how the file type opens, WITH WINDOWS. Just changed this setting in unity to VS manually and boom, all good!
    Thanks!
     
    John_MSFT likes this.
  39. AntonioPV

    AntonioPV

    Joined:
    Jul 20, 2020
    Posts:
    4
    i had the same problem but it was beacuase i changed the name of the script in unity but not in visual studio
     
  40. tridaryanto

    tridaryanto

    Joined:
    Sep 28, 2020
    Posts:
    1
    I had the same problem with Unity 2020 version and tried to work around with various procedures suggested on previous comments without success in getting Unity auto complete in my VS 2017. However when I switch to Unity 2019 it works fine without doing any of above procedures. Happy to see auto complete in VS works well now. I have no idea why 2020 version gave me this problem. Currently I just continue to use 2019 version.
     
  41. sss484376

    sss484376

    Joined:
    Sep 22, 2021
    Posts:
    1
    Thank you so much this works!!
     
    Schneider21 likes this.
  42. The_Ganti

    The_Ganti

    Joined:
    Dec 5, 2020
    Posts:
    2
    unity --> preferences --> external tools ... make sure its visual studio... then all the transforms and stuff are the right color if thats a problem
     
  43. fourmoth

    fourmoth

    Joined:
    Jul 31, 2022
    Posts:
    1