VS Code cant find references to some Unity Classes - unity3d

So, i just upgraded my Visual Studio Code Package from 1.2.3 to 1.2.4 and then it cant find the references to Cinemachine, UI and TextMeshPro anymore. With any other code editor it works well, even with Visual Studio 2019.I'm using Unity 2021.1.3f, and i cant find were to downgrade the version of the VS Code package.

Use the Unity Package Manager window (in Unity’s top menu: Window > Package Manager) to view which packages are available for installation or already installed in your project. In addition, you can use this window to install, remove, or update packages for each project.

Ok, so i found a solution, but its kinda weird and i hope they fix it by the next unity update.
for Unity 2021.1.3f1
First you need to create another Unity project. The VS Code package already come in the 1.2.3 version from default.
Close Unity after the project is created.
After that you need to copy the "Assets" folder and the "Project Settings" folder to your new project. Unfortunatly you have to manually install any package that you project depends on manually (Because i dont know how to copy/paste any package from one project to another) and after that dont update the VS Code package again.
I higly recomend creating a copy of your project (or having it in a git repository) before updating any package because Unity dont let you downgrade packages anymore.

Related

Unity gradle templates folder missing (2021.3.6f)

I installed unity 2021.3.6f with android build support (NDK and SKD) using unity hub.
Going into a project and attempting to build it on android platform , I get this error :
FileNotFoundException: Failed to find $C:/ProgramFiles/Unity/Hub/Editor/2021.3.6f1/Editor/Data/PlaybackEngines/AndroidPlayer/Tools\GradleTemplates\mainTemplate.gradle
I looked up in the directory and I don't even have the /Tools folder inside /AndroidPlayer.
Tried to reinstall unity and android module again but even after 2 times of reinstallation I still receive this weird error.
In unity Edit>Preferences>External-Tools>Gradle Installed With Unity is Ticked and marked to the /Tools folder which doesn't even exists
(there is also a warning below that saying I'm missing the recommended Gradle and I should install the recommended version using unity hub. but I already tried reinstalling everything)
I have used the unity android build before and it was always fine, perhaps this happens with the 2021.3.6f version that was released this week.
Can't find any solution to this anywhere, hope you can help.
Found the solution.
looks like the gradle folder has changed from AndroidPlayer\SDK\Tools to AndroidPlayer\SDK\cmdline-tools but the path still the old one inside Unity preferences.
Copy all folders and files inside cmdline-tools, create a new folder called Tools inside AndroidPlayer folder and paste there.
You can consider it as Unity Bug which will be fix in next update.
But for now please do the below workaround to fix this issue.
Go to the below location in the Unity installed folder
/Applications/Unity/Hub/Editor/2021.3.6f1/PlaybackEngines/AndroidPlayer/SDK/cmdline-tools/2.1
Now copy all the files and folders in this folder
Now Go back to the AndroidPlayer folder and create a folder Tools
Now paste copied files/folders in it and click on build and run.
Hope it will fix this issue.

Editing a Package Dependency as a Local Package

Overview
I have a project that uses a remote swift package.
I would like to edit this package in the same project so that I can refine it based on the usage.
Aim:
To do this I am trying to add the same package as a local package so that I can edit it.
Reference:
https://developer.apple.com/documentation/swift_packages/editing_a_package_dependency_as_a_local_package
Problem:
When I drag and drop the cloned folder containing Package.swift into the project, I can't see any of the local package source files in the project. (see screenshot)
I have been breaking my head over it. Any help on this would be much appreciated.
Xcode Version:
13.2 (13C90) (downloaded from the developer portal not the AppStore)
The reason you cannot see the content of the package is that you have it open in another Xcode instance.
You can only edit a package in one Xcode instance at a time.
I find closing down Xcode completely, then opening up the particular project that I want to edit the package in solves the problem.

Why unityengine.ui is not recognized?

I have a problem were i try to create a score system in my game where the player is getting points based on the distance he travelled, and the vs code is not recognising the "Using UnityEngine.ui;" I already tried to switch vs code to a lower version (I went to 1.1.3) but it didn't work. Here is my code:
You Could try a could try a couple of solutions -
Solution 1) Relaunch the unity Engine and VS code and check.
Solution 2) Go to Edit > Preferences > External Tools make sure Edit > Preferences > External Tools make sure the
'Generate all .csproj files'
is checked the in your IDE delete the:
Assembly-CSharp-Editor.csproj
Assembly-CSharp.csproj
Ecology.sln
files in the root of your project.
Close and reopen vscode.
Solution 3) Uninstall Unity Hub and reinstall again and try.
Solution 4) UnityEngine.UIElements; instead of unityEngine.UI;
UnityEngine.UI namespace is a part of the aditional package called Unity UI, and it seems you don't have it imported in the project.
Click on Window on the top-left menu in Unity Editor -> Select Package Manager -> Search for Unity UI -> click Install.
Well it seems that I already had ui tool installed so I tried to unistall the package and reinstall it. Vs code still throws an error sometimes but after I close it and open it again it works just fine. Thank you all for your help.
There seem to be a problem with the VScode package version 1.2.4, where regenerating csproj files from the preferences doesn't make Unity UI symbols available in vscode.
Going Back to version 1.2.3 solved the issue for me (from latest Unity 2020.3 LTS release).
These steps covered several possible issues:
https://stackoverflow.com/a/70977258/6046022
(just an overview, follow the link for the complete steps)
downgrade VSC package
re-install Unity UI
regenerate files
I have the same error what take me a lot of time to fix. And finally I found my reason that I meet a problem with duplicated extension in the same project. My one is "External Dependency Manager" what somehow installed already on Unity Package Manager, after I delete old Admob plugin and install new one what make install new "External Dependency Manager" without override or delete old one. That make Unity not work well.
So check and try to delete/uninstall "External Dependency Manager" in Unity Package Manager first then import new one will be fine. At least in my case
Hope this help

VSCode: Attempted to update project that is not loaded

I am using VSC for Unity v2019.4. I have the package from package manager installed. Also I have installed dotnet. The thing is that when I open VSC (through Unity) it shows in the output:
Attempted to update project that is not loaded: C:\workspaces\Unity\MyGame\Assembly-CSharp.csproj.
am able to use the editor, but the Intellisense is not working. I also have tried to change the omnisharp version to latest and it is still not working.
You can try a few things in order to make Visual Studio Code works properly with Unity.
First of all make sure that the editor package is installed in your project via Package Manager. Latest version should be installed.
Just to be sure it's better to close the project, delete Library folder and all .csproj and .sln files.
Then you can open your project in Unity again, wait it to load and try to remember to open scripts not by double clicking, but instead use right click in Project window and select Open C# Project. This will load the scripts without any issues.
In case anyone is still having this problem, try to install .net framework 4.7.1
Try uninstalling then reinstalling vs code and dotnet latest version. Also make sure vs code is installed in a folder with permissions to edit. If not it will not save any files until you run as admin

Can not start a new project as unity has "failed to load window layout"

Clicking "load default layout" does nothing (just rerenders the alert box), clicking "revert factory settings" also does nothing.
I've googled this issue and the common solution is to reopen unity and to reimport all assests except this is a brand new project. There is nothing in it to import.
I've tried creating a new project and it still gives me this error.
I'm running version 2020.1.5f1 and the target platform is Windows 64-bit
Quit Unity and do the following:
Go to "AppData\Roaming\Unity\Editor-5.x\Preferences\Layouts\default" or "~/Library/Preferences/Unity/Editor-5.x/Layouts/default" for mac, delete LastLayout.dwlt and copy Default.wlt
Paste Default.wlt into the "Library" folder of your project
Delete CurrentLayout-default.dwlt and rename Default.wlt to CurrentLayout-default.dwlt
Reopen Unity and load the project. The editor should open normally. You should now be able to create new projects as usual too.
the simple solution if it has yet to be tried would be to uninstall unity and reinstall.
if you have already tried that try updating to a newer version see if unity 2020.3 works to narrow the problem down a bit more. I had the same problem for me I just updated unity to a newer version and everything worked perfectly.
I tried the solutions posted by #carmelo343 and #Abhishek Dubey, but it still didn't work. My solution was to create the unity project using an older version (I used 2019.3.12f1), which shouldn't cause that layout error, then change the unity version to 2020.1.5f1 in Unity Hub (see below)
Unity Hub
go to "C:\Users<username>\AppData\Roaming\Unity\Editor-5.x\Preferences\Layouts\default"
Copy this file in your project library folder renaming it with "CurrentLayout-default.dwlt" and replace it with the old one.
Worked for me!!
I get this most every time I launch a project in Unity. Then I close and relaunch and all is fine. I am using a personal layout. I am using Unity 2020.1.8f1. These kind of things never happened before 2020 version.
just try this : in unity editor: Help -> Check For Updates -> uncheck the Check For Update
On Windows:
Open your project folder and delete the CurrentLayout-default.dwlt file
Go to "C:\Users<username>\AppData\Roaming\Unity\Editor-5.x\Preferences\Layouts"
Copy Default.wlt file to your project library folder and rename it to "CurrentLayout-default.dwlt"
my project opened normally without the warning.
I solved this by downloading and installing the latest Unity Hub.
I saved my project to a different location and was able to open Unity.