6

I am doing a small course for beginners about Unity 3D here. After importing all the assets from the unity asset store, as explained in the course, I get an error that probably shouldn't be generated, that says:

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

I have already searched for this problem but I have only found answers from older versions of Unity. I tried, as some said, to reimport all the assets and to close and re-open unity but both ways seem to not work for me.

This is the first line of code from the ChinemachineStoryboard file, that the compiler indicates: public UnityEngine.UI.RawImage mRawImage;

The second one (line 32) is just a comment so i don't understand how it could affect anything, but just in case, here it is: /// <summary>Image will be cropped if necessary so that the screen is entirely filled</summary>

8
  • Which version of Unity are you using ? Commented Jul 17, 2019 at 8:45
  • Will also add this in the main question. The version is 2019.3.0a4 Commented Jul 17, 2019 at 8:46
  • 2
    And why exactly are you using an alpha version full of bug ? Commented Jul 17, 2019 at 8:52
  • I looked for the last version and installed it. Which version would you mostly recommend to use? Commented Jul 17, 2019 at 8:56
  • Latest stable is 2019.1.10, Here you can download it through UnityHub store.unity.com/download?ref=personal. You should not use alpha or even beta versions if you are a beginner. Commented Jul 17, 2019 at 9:07

12 Answers 12

6

The issue is still present in Unity 2019.3.x and MS Visual Studio Code. I solved it with these steps:

  1. open the Package manager
  2. reinstall Unity UI + TextMeshPro modules
  3. upgrade Visual studio editor package to 1.2.0
  4. close Unity
  5. delete whole Library folder in the project
  6. open Unity

I tried these steps multiple times in various order therefore I'm not able to write exact order. Feel free to experiment :)

Sign up to request clarification or add additional context in comments.

Comments

3

First of all Unity 2019.3.0a4 is an Alpha version. You can see this on the a in the version. b would be a Beta version which still isn't stable for production.

In short: Don't use alpha or beta versions for production. They are not stable and full of bugs and errors. You should only use them for testing the absolutely newest features .. and only for that. That's the whole purpose of having alpha and beta versions.

Rather stick to the latest stable versions! You can recognize them on the f in the version. Currently it is 2019.3.0f1


The reason here in specific is that in the newer Unity versions the entire UI and Editor GUI was completely renewed and the now "legacy" UnityEngine.UI moved to a package in the PackageManager ... thus the namespace simply doesn't exist anymore if the according UI Package is not installed for your project.

3 Comments

This is now happening in F versions
@PCoelho as said in the answer: since 2019.2 the entire namespace UnityEngine.UI was moved to a package and eventually has to be installed via the PackageManager.
I have the exact same problem. I have 2019.3.4f1 and "Unity UI" package is already present and installed. There is no other UI package in the list, installed or not.
0

I ran into this error after importing an asset from the asset store.

After a lot of troubleshooting, I noticed that the asset imported a package called PackageManagerUI.

After uninstalling that package, the error went away.

I'm using Unity version 2019.3.7f1. Perhaps that package is built-in now.

Comments

0

I had this issue, and I tried (without success) a couple solutions found on the Unity forum.

  • The first thing I tried was rebuilding the project Library, which as the poster stated, doesn't make any sense, but a couple people said it worked, so I gave it a shot.
  • Next I tried changing the Visual Studio Code Editor package from 1.1.4 to 1.2.0, which also did not work.

Ultimately, what did solve it for me was returning from 1.2.0 to 1.1.4 (verified version), so I suspect that, in my case, uninstalling and reinstalling the Visual Studio Code Editor package would have resolved the issue.

2 Comments

UPDATE: And then, while working on project, right after adding a new script, the issue returns: "the namespace 'UI' does not exist in the namespace 'UnityEngine' "
But the project builds and runs without complaint - this is just a vscode/vs code editor package issue.
0

I found out (after trying literally everything i have found in the internet about this problem) that the developer tools of visual studio for unity may have a problem to write the new references as in unity 2019.3 (I have upgraded a project from 2017.1.0f3 to 2019.3.0f6) they moved the UnityEngine.UI to a package.

Deleting the tools folder from C:\ProgramFiles(x86)\Microsoft Visual Studio Tools For Unity\*version folder* and after that I ran the "API Updater" in unity fixed the problem for me. (maybe you should try do that before deleting the folder - for me it doesn't work)

I work in a standalone work environment so I can't let the NuGet Package Manager take care of it automatically because there is no internet. Hopes this is helpful in some way!

Comments

0

Adding my answer in April 2021, Unity version: 2020.3.2f1. I tried a number of things including removing the Unity Collaborate package. What I ended up finding was somehow in Visual Studio (Mac) some code had been added to the end. I'm not sure when or how it happened. It could have been when typing too fast and accidentally selecting some intellicode choice or something that happened when my mouse when on the fritz and I had to replace the batteries, but the following code appeared at the end of the script and bugged it. Removing it fixed everything.

    public class Text
    {
        public string text { get; internal set; }
    }

Comments

0

This is due to one issue. UnityUI.dll is present in the location of Library/ScriptAssemblies(library of your project).

If you will open your Assembly-CSharp.csproj ,search

<Reference Include="UnityEngine.UI">

if it is not present there add

For Mac Users

<Reference Include="UnityEngine.UI">
<HintPath>/Users/[Path to your current project]/Library/ScriptAssemblies/UnityEngine.UI.dll</HintPath>
</Reference>

For Window Users

<Reference Include="UnityEngine.UI">
<HintPath>Library\ScriptAssemblies\UnityEngine.UI.dll</HintPath>
</Reference>

Comments

0

I see this problem maybe from too long time ago. But I would like to share my solution if someone need it and the same case with me.

Basically, the problem happen right after I remove old version Admob and import new version and the problem show up. After doing many way to solve and the error still there. I do these simple step

  1. Remove the new Admob version -> error gone
  2. Import new Admob version again -> fixed

I am not sure why or maybe in my first import having some process not work. I believe it can be the same for other plugin/extension in import process. So just delete new one and import again

Hope it help

Comments

0

Please add Ui pacakage from package manager enter image description here

1 Comment

This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
0

I was porting an old project to a newer version of Unity and after trying all the provided solutions with no success, I simply installed the Unity UI package from the Unity Registry Solved My Problem!

Comments

0

Import Unity UI package in Windows->package Manager->Unity Registry-> Unity UIenter image description here

Comments

-1

Just open the Solution Explorer of your IDE and go to References and look for UnityEngine.UI, there must be a warning sign over it, just click on it and it will be resolved. if there's no UnityEngine.UI you must add it yourself.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.