VSCode: Attempted to update project that is not loaded - unity3d

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

Related

VS Code cant find references to some Unity Classes

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.

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

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.

How can I fix "build failed, do you want to continue"? In Visual Studio Code

I got an error when trying to debug Java code in Visual Studio Code.
The error is below
build failed, do you want to continue?
I have tried clearing the workspace, but it doesn't work. How can I fix this issue?
The problem was solved.
I resolved this issue by clearing the workspace cache in Visual Studio Code. Here is a link to the relevant page: Visual Studio Code Clean Workspace Directory. I had renamed a number of folders, class names and packages.
Apparently the Red Hat Developer plugin managed to get out of sync. The .classpath file was out of sync with the POM file. Wiping out the workspace cache caused the plugin to recreate project data from the Maven specification. The problem was solved. I am not sure, but if anyone from the Red Hat project reads this, it looks to me like a bug, or deficiency. In any event it can be worked around.
Original answer:
I think Liu Bei was not clear enough. I am experiencing the same issue. I have a project that builds perfectly in Maven and when I launch the debugger in Visual Studio Code this notification appears in the lower right-hand corner of the Visual Studio Code window.
Obviously the "Debugger for Java" extension thinks there is a build problem. However there are no errors reported in the PROBLEMS, OUTPUT, DEBUG CONSOLE or TERMINAL tabs.
The project builds, and packages in Maven just fine and it can be debugged in attach mode which is tedious at best.
There is something going on in Visual Studio Code that's not being reported anywhere that I can find. I suspect the RedHat Visual Studio Code plugin for Java is in the mix, but I need help figuring out how to work around the issue.
I have to say that we are spending way too much time resolving issues with tools and dependencies and not enough time on the app. The project we are working on is intended for open source distribution. The Spring Framework seems ideal for our purposes, but the tooling, not so much. We are not very far into the project and I am already receiving pressure to switch to ASP.NET Core.
I really need a little help...
This didn't work for me, but I found out what did.
First of all, looking at the Java Dependencies plugin gave me a hint that something was out of sync. The name of my application (artifact) did not match the name in the Java Dependencies tree view.
This was fixed by clearing the Visual Studio Code workspaceStorage folder completely!
This folder was in my case located in (Windows 10):
C:\Users\<myuser>\AppData\Roaming\Code\User\workspaceStorage
If you can't find it at this location, simply search for the folder workspaceStorage.
Next press Ctrl + Shift + P (in my case) to open the Visual Studio Code action prompt. Then choose the command:
Java: Open Java Language Server Log File
This will open a log file which is normally not displayed when building your Java code, and will tell you exactly what went wrong with the build.
In my case it was a conflict as I had two AppConfig.java files, one in main and one in test. Maven handles this fine, but apparently the Visual Studio Code Java builder does not.
Obviously these are bugs in the plugins which I will report to the GitHub contributors, but for now we will have to live with a little manual work.
Still I hope this helps all of you frustrated Visual Studio Code Java developers out there.
It worked for me to change the user setting in file setting.json to "java.debug.settings.forceBuildBeforeLaunch": false in Visual Studio Code, which will disable the check before run/debug.
Build failed error in Visual Studio Code
This error occurs because in your workspace folder the other source code has some errors in it.
So create a new folder and make it as a workspace folder and then write your codes in that folder and run it.
I had that error also and it worked for me, so check for yours.
Using OS X, I managed to overcome this problem. You can either access it from your Terminal or simply use a
shortcut (Command + Shift + C).
Select Base System and Library. Look for the Java folder and click on the Java Virtual Machines folder.
Check if is there the actual version of JDK (most up to date). I've noticed that I had two JDK folders one probably inherited from a previously installation and the most up-to-date Java 15. I dragged 'jdk-14' to the waste bin. Enter password, close finder and restart Visual Studio Code.
It works fine now!
For me, the problem was that I created a folder within a folder for arranging my Java program files with the reference to data structures. In the log file, it was showing that the .java file in the inner folder was not on its project's build path.
Just after deleting that folder and completely deleting all the files in the workspace folder manually in the location C:\Users<myuser>\AppData\Roaming\Code\User\workspaceStorage, this problem was solved!
I fixed this problem by doing the following steps:
Step 1: Opening Visual Studio Code settings (bottom left) https://i.stack.imgur.com/xPlkj.png
Step 2: Searching "Java debug" and selecting Java Debugger under Extensions https://i.stack.imgur.com/797M3.png
Step 3: Find Force Build Before Launch and uncheck it https://i.stack.imgur.com/igtRa.png
And you're done!
First of all, check carefully the errors on Visual Studio Code log and try to not get biased by the community common errors. To do this, press Ctrl + Shift + P to open the Visual Studio Code action prompt. Then choose the command:
Java: Open Java Language Server Log File
By doing this you can find the exact exception that is happening. In my case, I had two exceptions:
java.lang.NoClassDefFoundError: javax/annotation/processing/AbstractProcessor
And
java.lang.NoClassDefFoundError: com.demo.myapplication
So, I was biased to think that error was related to the Java version or stuff like that, but it was related to a Lombok extension installed in Visual Studio Code.
In the end, I found this thread and tested this solution and it worked like a charm.
Here is the solution explained by him:
Finally I got it working. The issue is with the additional argument -Xbootclasspath added by the Lombok extension to the java.jdt.ls.vmargs. I figured it out by integrating the Lombok with eclipse and opened the eclipse.ini file for the changes.
I uninstalled the vscode-lombok extension;
I downloaded the lombok.jar (version 1.18.6) file from https://projectlombok.org/download;
In Visual Studio Code, in settings.json, for java.jdt.ls.vmargs key, I added the argument
-javaagent:"PATH_TO_DOWNLOADED_LOMBOK_JAR_FILE"
A last necessary step (missed by the GitHub guy) is to reinstall the Lombok extension.
I had the same problem.
I just downloaded this provided for Visual Studio Code,
Extension Pack for Java.
Click on the link, download and open it. It will automatically configure Visual Studio Code for Java.

Java FX in Eclipse on Mac OSX 10.7

Since I had problems with compiling JavaFX Code from Eclipse on Mac OSX 10.7 using java development kit 1.7.0_04 i just want to share my intermediate solution with interested people:
Problem:
The jfxrt.jar and other .jar files are not recognized when selecting the new jdk issued by oracle as a new jre/jdk in eclipse.
The jdk is installed within /Library/Java/JavaVirtualMachines/1.7.0.jdk which is recognized as a package.
Adding the path /Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/jre/lib/jfxrt.jar later is not possible since the file open dialog of eclipse does not allow to navigate to the inside of the package
Solution:
Create a symbolic link from outside the package to inside the package and follow the link within the file open dialog.
Simply go to a terminal and execute the following:
[0-/Library/Java/JavaVirtualMachines]:sudo ln -s 1.7.0.jdk/Contents/ 1.7.0.jdk_Contents
This creates the symbolic link 1.7.0.jdk_Contents using super user permissions (sudo).
By this compilation and execution of JavaFx code works fine and as expected.
It's not need to do all said before, just use a allmost unknown behaviour of Finder dialogs: Drag & Drop.
You can open a Finder window from console with:
open /Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/jre/lib
so yo will see jfxrt.jar and other .jar files. Drag this files to Eclipse's Add external jar dialog window... et voila!
Dependencies satisfaced! No link needed!
The initial JavaFX 2.1 release in jdk1.7.0_u4 was not supported by e(fx)clipse.
This support thread indicates that the maintainer of the plugin is aware of the incompatibility issue is pushing a patch to the plugin repository to fix the issue and in the meantime recommends using a JavaFX 2.2 preview build instead.