The type or namespace name 'UI' does not exist in the namespace 'UnityEngine' HELP!

So! Literally all I have done that is causing this issue is the following:

using UnityEngine;
using UnityEngine.UI;

public class GameMode : MonoBehaviour {

I have only added this using statement to the script, and it is throwing an error.

using UnityEngine.UI;

What is going on here, and how do I fix it? This seems like some inherent problem with the engine not being able to fetch the dlls or something.

The error is as follows:

Severity Code Description Project File Line Suppression State
Error CS0234 The type or namespace name 'UI' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?) VillageClicker.CSharp D:\Games\Unity Games\Casual\VillageClicker\Assets\TavernProject\Scripts\GameMode.cs 2

I would greatly appreciate any helpful advice. :)

P.S I have already tried Assets -> Reimport All but to no avail.

1 Like

From the solution explorer of your IDE (MonoDevelop/VisualStudio/whatever you use) check the References.
If there's no UnityEngine.UI -> add it (process will differ depending on IDE).

Either way - did you change any settings recently? It should be added by default unless you were importing a project that had it explicitly removed.

Edit: added sample screenshot from MonoDevelop

Hey! Thanks for the quick response!

UnityEngine.UI already exists in the References.


This issue still has not been resolved. Would appreciate any additional input as to what might help fix this! :)


This is odd. What version of Unity are you using?

The project was created in Unity v5.3.2 (I believe) and I just updated to v5.3.4 yesterday.

That rules that out. Occasionally we get people who can't find it in 4.5.

Tried turning it off and back on again? Sometimes restarting Unity and VS helps.

1 Like

Yes. Unfortunately no luck! I wonder if something went wrong in the hotfix update. Perhaps I'll try a reinstall of the engine when I get home today. :)

Looks like if I create new projects, those projects work fine with importing the UnityEngine.UI library. Very strange! I suppose I'll just remake the project and pull the files over. Case closed, sort of.

1 Like

I had the same problem, the problem came on my case from the unitys created 'Library' folder, which is at the root of your project. It should be safe to remove without any care but i suggest to make backup before doing so. Unity will just regenerate it when you reopen it (Heavily suggest to close unity before removing this folder).


Apparently they replaced UI with UIElements. UnityEngine.UI.Text replace with UnityEngine.UIElements.TextElement and then the error should go away.

1 Like

This post was 3 years ago...and it is still UnityEngine.UI.Text

UIElements is for editor UI.


Remove Library folder from Project and open Project again resolved this issue.


Very good advice. If in doubt, delete the library.


Obviously anyone coming here reading this should factor in that doing this will trigger a full reimport and new metadata being created for a lot of stuff. Probably not an issue for most, but on a big big project that can be a long time reimporting, so try to make this your last port of call when troubleshooting!


Why would you make the thing most likely to resolve the issue the "last port of call" ?

[quote=“kdubnz”, post:16, topic: 624529]
Why would you make the thing most likely to resolve the issue the “last port of call” ?
For exactly the reason GameDevCouple_I mentioned. In a large project, it can hours to rebuilt the Library folder. Depending on the issue, a quicker solution [like this]( page-4#post-2416458) might be preferable.

1 Like

Here's what worked for me:

Note that removing the Library folder permanently (as someone else suggested) will remove all objects from your scene. But using this method will save them:


  • Close Unity and any code editors you have open
  • Make a backup of the Library folder from your project folder to your desktop
  • Delete the Library folder from your project folder
  • Open your project (Unity will rebuild the Library folder)
  • Close Unity
  • Delete the newly generated Library folder
  • Move the Library folder (you backed up earlier) from your desktop back into your project folder
  • Open your project
  • Open one of your scripts
  • UnityEngine.UI should be fine now

Not sure why this works or if it will have any effect on the rest of your project. My project was fairly small and I didn't see any problems afterwards.

Perhaps someone with more knowledge could point out any problems with this method?


As weird as this approach is, this helped me fix my problem.
I am working on Linux in Visual Studio Code for what it's worth.

For whatever reason the issue started happening right after I worked some more on the Scene

Deleting the Library folder didn't fix it for me.

What worked was just updating the Visual Studio Code Editor package in Package Manager from 1.1.4 to 1.2.0.