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

12

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>

Therapeutics answered 17/7, 2019 at 8:42 Comment(8)
Which version of Unity are you using ?Steamship
Will also add this in the main question. The version is 2019.3.0a4Therapeutics
And why exactly are you using an alpha version full of bug ?Steamship
I looked for the last version and installed it. Which version would you mostly recommend to use?Therapeutics
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.Luca
the latest stable version is currently 2019.1.10 and you should stick to it. I had a very similar question lately but can't find it .. but basically it had exactly the same issue using the alpha versionBrahmi
@Luca you shouldn't use them for production at all actually .. only for testing the absolutely newest features ;)Brahmi
Thanks very much to all of you. I have followed your instructions and it now works fine!Therapeutics
B
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.

Brahmi answered 17/7, 2019 at 9:17 Comment(3)
This is now happening in F versionsTransubstantiation
@Transubstantiation 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.Brahmi
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.Melise
P
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 :)

Pradeep answered 6/4, 2020 at 19:31 Comment(0)
B
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.

Brahmi answered 17/7, 2019 at 9:17 Comment(3)
This is now happening in F versionsTransubstantiation
@Transubstantiation 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.Brahmi
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.Melise
C
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!

Crocein answered 25/2, 2020 at 7:53 Comment(0)
O
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.

Opinionative answered 1/4, 2020 at 4:53 Comment(0)
S
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.

Sandhog answered 5/5, 2020 at 19:4 Comment(2)
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' "Sandhog
But the project builds and runs without complaint - this is just a vscode/vs code editor package issue.Sandhog
P
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; }
    }
Procession answered 29/4, 2021 at 3:41 Comment(0)
M
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>
Maurinemaurise answered 22/3, 2022 at 3:27 Comment(0)
U
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

Unrivaled answered 29/10, 2022 at 5:59 Comment(0)
J
0

Please add Ui pacakage from package manager enter image description here

Jeanett answered 10/7, 2023 at 7:49 Comment(1)
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 ReviewSustain
D
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!

Dumbwaiter answered 24/7 at 7:7 Comment(0)
N
0

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

Nubble answered 29/7 at 9:22 Comment(0)
C
-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.

Constituent answered 29/9, 2020 at 14:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.