4

I've tried a lot of things already but nothing worked. enter image description here

I've already reimported, deleted, and reinstalled stuff. I'm using unity 2019.3.0f6 and vs code 1.42.1.

rminaj
  • 560
  • 6
  • 28
  • Are you using the vs code package? – BugFinder Feb 24 '20 at 15:32
  • The Visual Studio Code Editor on unity? I have the 1.1.4 and already reinstalled it. – rminaj Feb 24 '20 at 16:08
  • Does this answer your question (second section): [The type or namespace name 'UI' does not exist in the namespace 'UnityEngine'](https://stackoverflow.com/questions/57071884/the-type-or-namespace-name-ui-does-not-exist-in-the-namespace-unityengine/57072477#57072477) ? In other words .. did you make sure the UI package is installed via the PackageManager? – derHugo Feb 24 '20 at 16:22
  • I do have Unity UI on the package manager. – rminaj Feb 24 '20 at 16:26
  • do youh ave any other errors showing in unity for your code? – BugFinder Feb 24 '20 at 16:47
  • Just "Curl error 56: Receiving data failed with unitytls error code 1048578" which has been there since I started using Unity. – rminaj Feb 24 '20 at 16:49

4 Answers4

7

I found the answer here. https://issuetracker.unity3d.com/issues/upgrading-projects-to-2019-dot-2-0b1-can-introduce-reference-errors-to-unityengine-dot-ui

For those who are facing this problem yet:

1. Remove all .sln and .csproj files

2. Make sure the "Generate all .csproj files." checkbox is checked on Preferences

3. Reopen C# Project

The guy on the comments showed something that even the official VS Code and Unity Integration page didn't mention. And the integration page is already very old. The Unity ui shown there is already different compared to the current 2019.3.0f6 that I am using.

Community
  • 1
  • 1
rminaj
  • 560
  • 6
  • 28
  • I did this and now i can open the project on VS 2017, but not on VS Code.. in fact VSCode doesn't open the folder of the project.. – AitorFDK May 14 '20 at 11:57
  • Did you set VS Code as your editor in External Tools on Unity? Also, you might not have setup your Unity to VS Code integration well. It took me a week to setup my VS Code to work on Unity. – rminaj May 15 '20 at 06:48
  • 1
    Yes, I don't really understand why it's so difficult, but I'll take some time to read how to better integrate VSCode... – AitorFDK May 16 '20 at 16:37
  • I can confirm this solution is working with VSCode 1.45.1 and Unity 2019.3.0f6. Thank you. – willnode May 17 '20 at 08:51
2

I used Visual Studio Community 2017 and had the same problem (using Unity 2019.3.12f1). After trying a lot of things (none worked), including the answers provided here, what finally worked for me was the following:

  • Install Visual Studio Community 2019 (I also selected "Game development with Unity").
  • In Unity select this one as the "External Script Editor" (Edit -> Preferences... -> External Tools).
  • Fix broken references between projects within the solution in Visual Studio by first removing the references and then adding them again (Project -> Add Reference...). (Solution to a new problem that arose after switching to Visual Studio Community 2019).

This last step has to be done again when Unity regenerates .csproj files. I found that the <ReferenceOutputAssembly>false</ReferenceOutputAssembly> tags in the generated .csproj files is responsible for this (after re-adding references in Visual Studio, these tags are removed when saved). I verified that manually removing those lines from the .csproj using a text editor also works. I'm not sure if this setting can be managed somehow within Unity.

Bert Regelink
  • 2,696
  • 23
  • 17
  • Looks like this will be solved in Unity 2020.1 judging from their source code: 2019.3: https://github.com/Unity-Technologies/UnityCsReference/blob/cabb1d153f6c442cc8ea27a84a6ef93ecb48b8fd/Editor/Mono/VisualStudioIntegration/SolutionSynchronizer.cs#L619 2020.1: https://github.com/Unity-Technologies/UnityCsReference/blob/37e5769851d73b55aaeab010131c93a9bfab6ffa/Editor/Mono/VisualStudioIntegration/SolutionSynchronizer.cs#L538 – Bert Regelink May 02 '20 at 20:16
  • Really? That would be nice. This problem is really annoying. – rminaj May 15 '20 at 06:50
0

Remove the Library folder from the project and open it again to resolve this issue.

This will trigger a full reimport and new metadata will be created for a lot of stuff. It's probably not an issue for most, but on a big project, it can take a long time to reimport everything!

In case you want to take a safer approach, do the following:

  1. Close Unity and any code editors you have open
  2. Make a backup of the Library folder from your project folder to your desktop
  3. Delete the Library folder from your project folder
  4. Open your project (Unity will rebuild the Library folder)
  5. Close Unity
  6. Delete the newly generated Library folder
  7. Move the Library folder (you backed up earlier) from your desktop back into your project folder
  8. Open your project
  9. UnityEngine.UI should be fine now

Hope this helps!

Lorenzo Goldoni
  • 555
  • 6
  • 22
0

Thats possibly, because you have two UnityEngine.UI references or namespaces.

Here is a possible solution: https://www.google.com/amp/s/pvs-studio.com/en/amp/blog/posts/csharp/0834/