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:
    2,887
    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.
     
  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,670
    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:
    14,382
    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:
    14,382
    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.
     
    KIra_King and Hiyek like this.
  13. markgrossnickle

    markgrossnickle

    Joined:
    Aug 21, 2017
    Posts:
    31
    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]
     
  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
  21. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    14,382
    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:
    14
    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:
    14,382
    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