Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

UnityEngine.UI Deprecated in Unity 2019.2

Discussion in 'Scripting' started by PatrickVDM, Nov 17, 2019.

  1. PatrickVDM

    PatrickVDM

    Joined:
    Nov 17, 2019
    Posts:
    7
    Hi All,

    I have spent over 4 hours banging my head and keyboard on google trying to figure out why "using unityengine.ui;" doesn't work anymore for Unity 2019.2. I found out it was deprecated. I did not know that and now I wish I didn't upgraded to 2019.2 because the documentation for 2019.1 still has those coding references and 2019.2 doesn't. I have read they have moved it as a package and some people are happy about it. But no one can tell me how to fix it is my main problem right now. That problem is how get access that library because the using statement doesn't work anymore. Because they moved it to a package, I have been googling how to reference this package in my code but getting no where. No I am not using the Alpha or Beta Version.

    Can anyone help please?
     
    Reaperonlinee and Lars-Steenhoff like this.
  2. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    995
    Try this

     
  3. Deleted User

    Deleted User

    Guest

    I use old scripts that use UnityEngine.Ui without any problem. No error message, not warning about UnityEngine.UI being deprecated.

    Creating new script using UnityEngine.UI is not a problem either; they work in 2019.2. The old 2018.3 documentation can still be used, I guess: https://docs.unity3d.com/2018.1/Documentation/Manual/UISystem.html.

    It's weird though that it has disappeared from the 2019.2 and 2020.1 pages. They must have been moved somewhere and nobody warned us.

     
    Ryiah and Lars-Steenhoff like this.
  4. Deleted User

    Deleted User

    Guest

    Last edited by a moderator: Nov 17, 2019
    Dave_Bowman likes this.
  5. PatrickVDM

    PatrickVDM

    Joined:
    Nov 17, 2019
    Posts:
    7
    I did a search in the project folder for the .asmdef file extension. But none reference the project name. only the following

    Unity.com.unity.vscode.Editor
    com.unity.ide.rider
    UnityEditor.TestRunner
    UnityEngine.TestRunner
    Unity.CollabProxy.Editor
    Unity.CollabProxy.EditorTests
    Unity.TextMeshPro
    Unity.TextMeshPro.Editor
    Unity.TextMeshPro.Editor.Tests
    Unity.TextMeshPro.Tests


    Still back to square one unless you are not specific enough on your instructions or could be for an older version of unity.
     
  6. PatrickVDM

    PatrickVDM

    Joined:
    Nov 17, 2019
    Posts:
    7
    Come On. You got to be serious. This is even happening in the 2019.3 Version.
    I am getting really ticked off.

    Unity Documentation doesn't help.
    Who has a clue?

    I have no package namespace access to UnityEngine.UI
     
    Reaperonlinee likes this.
  7. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,937
    Have been working with Unity 2019.2 on a daily basis since it was first released and I'm not having any of the troubles you describe here. Check the package manager for your project (Window -> Package Manager). If there isn't anything in the package manager then I'd suggest resetting your project's packages by clicking Advanced -> Reset Packages to Defaults.

    upload_2019-12-5_1-15-15.png

    Alternatively you can navigate to the packages documentation by going to the manual, expanding Packages in the side bar, and then expanding Built-in Packages. Click the one you want to check and then on the page that loads click the version. It's totally convoluted.
     
    taeseong_park likes this.
  8. PatrickVDM

    PatrickVDM

    Joined:
    Nov 17, 2019
    Posts:
    7
    The Packages are installed for the project. Yeah Right. Which I have found out now. The Packages folder on each package is empty in the project folder. What unity is doing is getting it from another source not the project it's self. Hench why the namespaces are not registering. Now this is a clean project from scratch for 2019.3 Full Release. So how to we go about fixing it as copy and pasting does some weird things to the packages say it is not for production use. Anyone have this issue?
     
  9. Vectorbox

    Vectorbox

    Joined:
    Jan 27, 2014
    Posts:
    232
    Although some users may find the change useful (?), it doesn't really help when creating libraries in Visual Studio which, out of preference, I've always installed as a separate entity
     
    Last edited: Feb 26, 2020
  10. PatrickVDM

    PatrickVDM

    Joined:
    Nov 17, 2019
    Posts:
    7
    This doesn't really help fix the problem.
     
  11. BritTiggs

    BritTiggs

    Joined:
    Apr 2, 2018
    Posts:
    3
  12. Wolfram

    Wolfram

    Joined:
    Feb 16, 2010
    Posts:
    263
    This is probably a stupid question, but I have to ask: you explicitly wrote that you use "using unityengine.ui;". Is this really exactly as it is typed in your code (i.e., lowercase)? The correct, case-sensitive line should be
    using UnityEngine.UI;
     
  13. Wolfram

    Wolfram

    Joined:
    Feb 16, 2010
    Posts:
    263
  14. MrGreenish

    MrGreenish

    Joined:
    Oct 20, 2019
    Posts:
    34
    I solved it by creating a new Unity project. I export the assets from the old project (creating prefabs of terrain and game objects I had created) and imported them in the new project.

    Try creating a new Unity project, make a C# script and try to use UnityEngine.UI in the new project. If you don't get the error message, you should be able to solve the problem the same way I did.
     
  15. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    Related to this... is the package version of UI now being phased out?

    Screen Shot 2020-02-26 at 6.57.37 pm.png
     
  16. unity_iy4uDON9bdkqZw

    unity_iy4uDON9bdkqZw

    Joined:
    Dec 31, 2019
    Posts:
    1
    Reaperonlinee likes this.
  17. Bmco

    Bmco

    Joined:
    Mar 11, 2020
    Posts:
    69
    Ok, ok, ok....I'm about 2 hours banging my head against the keyboard and I got lucky. I'm surprised no one suggested this option yet...but my problem may have been slightly different.

    I was separating my project into different assemblies (creating a .asmdef file) and suddenly lost all my UnityEngine.UI references...

    Currently using 2019.3.0a3.

    If you look through the Packages folder there is : Packages\Unity UI\Runtime\Unity.ugui.asmdef

    I was looking for UnityEngine.UI and it wasn't there. However, if you add a reference to Unity.ugui in the references section of your .asmdef file, then in your scripts, the code "using UnityEngine.UI" works!

    Sweet!
     
    Vectorbox and Kurt-Dekker like this.
  18. userdei

    userdei

    Joined:
    Feb 8, 2019
    Posts:
    1
    There are several .asmdef files.
    Which one did you edit?
     
  19. unity_ahTs1HvgBBT26g

    unity_ahTs1HvgBBT26g

    Joined:
    Jul 1, 2020
    Posts:
    1
    THIS IS GOLD. took all asmdef from my game and got rid of all errors. Man, I wanna kiss you
     
  20. Krnitheesh16

    Krnitheesh16

    Joined:
    Apr 22, 2020
    Posts:
    14
    Hi, I can't find any (project-name).asmdef file in my project. I found only .csproj files
    Any clue?

    Thanks in advance
     
  21. iHeartGameDev

    iHeartGameDev

    Joined:
    May 3, 2019
    Posts:
    12
    Just adding to this that I deleted the UnityEngine.UI.csproj file and then did "Reimport All" and it worked for me. Nothing else did up until that point.
     
  22. Andreas_GP

    Andreas_GP

    Joined:
    Jan 3, 2016
    Posts:
    1
    I had the same problem and did not have any asmdef files. Tried everything and nothing helped. Finally got it working simply by updating my visual studio community from 2017 to the latest.
     
  23. waverz

    waverz

    Joined:
    May 23, 2017
    Posts:
    17
    I am really shocked!! all these errors because one command which is (using UnityEngine.UI)
    this is so confusing and frustrating!

    Also beware of deleting ".asmdef" files ruins the whole project even I restored them but still the project unstable!
     
    Last edited: Feb 22, 2021
  24. Arslanmirza313

    Arslanmirza313

    Joined:
    Oct 12, 2020
    Posts:
    3
    Thats Amazing i was searching for this issue for 3hours and finally i resolved it through this reference.Thanks a lot . Worked for me.
     
  25. tlskillman

    tlskillman

    Joined:
    Dec 12, 2015
    Posts:
    16
    FYI - Visual Studio Code Editor 1.2.4 broke my app. All UnityEngine.UI become unresolved.
     
  26. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    39,571
    This may help you with intellisense and possibly other Visual Studio integration problems:

    Sometimes the fix is as simple as doing Assets -> Open C# Project from Unity. Other times it requires more.

    Other times it requires you also nuke the userprefs and .vsconfig and other crufty low-value high-hassle files that Visual Studio tends to slowly damage over time, then try the above trick.

    Barring all that, move on to other ideas:

    https://forum.unity.com/threads/intellisense-not-working-with-visual-studio-fix.836599/

    Also, try update the VSCode package inside of Unity: Window -> Package Manager -> Search for Visual Studio Code Editor -> Press the Update button

    Also, this: https://forum.unity.com/threads/no-suggestions-in-vscode.955197/#post-6227874

    ALSO:

    UnityEngine.UI is now a package:

    https://forum.unity.com/threads/where-did-the-ui-option-in-the-create-menu-go.1134796/#post-7290742

    Annoying possible issue circa October 2021:

    https://forum.unity.com/threads/unityeditor-ui-csproj-not-found.1177432/
     
  27. tlskillman

    tlskillman

    Joined:
    Dec 12, 2015
    Posts:
    16
    @Kurt-Dekker thanks for you input on this issue. The workaround I found was that Visual Studio suggested adding a reference to 'UnityEngine.UI.Player'. I already had 'UnityEngine.UI' so didn't think it was necessary. But after trying other things that didn't work, I just clicked on the "Add reference to 'UnityEngine.UI.Player' option, and the syntax errors went away.

    Now here's the odd bit, when I looked at my 'using' commands, there was still only UnityEngine.UI. No 'using' command referencing UnityEngine.UI.Player.

    So I went on my merry way, never understanding what just happened. No other problems surfaced so I guess it fixed itself...

    I hope Microsoft still looks into this.

    Thanks again Kurt-Dekker for all the other ideas that I might need in the future.

    ---------------- Summary ---------------
    After upgrading Unity Version 2020.3.26f1 with the recommended Visual Studio Code Editor 1.2.4 package I got this:
    upload_2022-3-6_15-34-35.png

    With suggested corrections like this:

    upload_2022-3-6_15-25-33.png

    After selecting "Add reference to 'UnityEngine.UI.Player'", note no reference to UI.Player.
    upload_2022-3-6_15-32-47.png

    All errors gone.
    upload_2022-3-6_15-36-2.png