Here, when I open the highlighted script in a Unity Project:
The visual studio opens and there's no solution explorer:
and even if I add it from View tab, there's nothing in it to be accessed or browsed.
Due to this I'm not able to access Unity classes like in this example Vector3 class cannot be accessed which can be noticed as it's not color coded.
How can this problem be solved?
Sometimes your visual studio is out of sync with your Unity. Some methods I used to fix this are:
Greate a new script and delete it
Editor->prefences-> and set your coding application to visual studio 2019 or any other version
you need to update your visual studio to latest update.
if this didn't work out you'll have to change to vs 2022
Related
As seen in the image bellow, references are not showing up in visual studio.
I was just using visual studio and i closed the project opened some other project and opened the unity project again in visual studio.
But then none of the references shows up and i cant really fix it.
Any ideas on how to fix this?
In Unity Editor try:
Edit -> Preferences... -> External Tools -> Regenerate project files
This problem happened to me, I couldn't solve it, I reinstalled visual again and downloaded c# plugins and module so it worked
The code pair may not be able to compile due to not referencing the relevant library files and namespaces
I know this has already been addressed many times, but really I have tried everything that I found and I just can't get the autocomplete to work. I first tried VS Code but I could not get it to work, then I opened Visual Studio and tried everything I found in different forums but nothing.
I have already tried:
Downloading Unity tools for Visual Studio
Regenerating project files
Setting Visual Studio as preference in Unity.
Redownloading Visual Studio.
I think I may have missed something in the External tools window, but I am not sure about what.
External Tools Window
My editor with the file structure
just like the title Unity Scripts edited in Visual studio don't provide autocomplete. i am trying to make a rigid body and as you can see it doesn't recognize it, some help? By the way i can't change the "External script editor" to something else but "open file by extension:
Your installation of Visual Studio is probably missing the Visual Studio Tools for Unity extension.
Try this installation guide: Get started with Visual Studio Tools for Unity
There is a previous forum that provides guidance on this issue which is still relevant in 2021:
Unity Scripts edited in Visual studio don't provide autocomplete
One solution that worked for me that was not in that forum was going to the Solution Explorer tab in Visual Studios. Right click the solution and hit resolve errors. This may fix the issue.
I start to use TextMesh Pro in unity3D 2018 to render text and it works well when I set it up in inspector. But by the time I try to reference it in the script in visual studio 2017, I find the vs always warn me there is no such a class. Could anyone give me a suggestion?
You should upgrade Unity to the latest version. It appears there is a problem with TMPro.
An issue related to this has been discussed on the Unity Forum
I'm not sure, but I think you need to use the namespace from text mesh pro "using TMPro" and variables look like this "public TextMeshProUGUI aTextMeshProField;"
I had the same issue, and none of the following worked for me: updating Visual Studio 2019 through Visual Studio Installer, updating to latest Unity LTS 2020.3 and the visual studio editor package on Unity Package Manager.
Then I saw there were issues reported years ago regarding namespaces and packages here, to I went to Unity > Edit > Preferences > External Tools and I unticked "Generate .csproj files for Registry Packages", and that did the trick for me.
I've installed Visual Studio 2015 and Visual Studio 2015 Tools for Unity and I had no problem in using Visual Studio as my default editor in Unity, however I've noticed that Unity's keywords and methods do not auto complete, only the VS do.
For example: GetComponent<>, or OnGui() and Input.GetMouseButton, these are specifically from Unity, when I was using MonoDevelop it displayed the available options of methods when I was typing Input.GetMouse... and if I clicked CTRL + Space it auto completed.
I would like to know if is there any way that I can make Visual Studio recognize Unity API.
Since I am new in Unity and C# I don't know if this is a default behavior, if I should set up something to enable this auto complete feature or if something is wrong and it should be working and somehow it is not.
I would appreciate any help.
Thanks in advance.
Import Unity VS Tools' package into unity, open visual studio and use Ctrl-Shift-Q to call Quick MonoBehavior Wizard
Configure Shortcuts: http://unityvs.com/documentation/shortcuts/
Good luck