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:

- 3,069
- 5
- 41
- 76

- 108
- 2
- 9
6 Answers
You 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 then 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;

- 346
- 4
- 11
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
.

- 179
- 4
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.

- 108
- 2
- 9
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).

- 11
- 1
-
Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Felix Arnold Feb 03 '22 at 15:16
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

- 482
- 4
- 11
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

- 143
- 1
- 7