Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

using UnityEngine.UI not working

Discussion in 'Scripting' started by BetrayedPickle, Jun 30, 2020.

Thread Status:
Not open for further replies.
  1. BetrayedPickle

    BetrayedPickle

    Joined:
    Mar 30, 2019
    Posts:
    119
    So recently I've had this problem where I enter using UnityEngine.UI, VS doesn't recognize it. It doesn't spark an error for unity, so I've ignored it and all my scripts have worked fine. But now everything is getting cluttered up and it's hard to see the actual errors. Does anyone know how to fix this?
     
    Vinyks and zanouk like this.
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,762
    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.

    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

    (Edited 7/24/2021 with my latest blurb)
     
    Last edited: Jul 24, 2021
  3. BetrayedPickle

    BetrayedPickle

    Joined:
    Mar 30, 2019
    Posts:
    119
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,762
    Sorry to hear that. Well, if you find a link that works, please come back here and update this post... I'll grab it because I see this question about twice a week. Perhaps someone from Unity can chime in here with additional guidance?

    Another thing to try is from Unity, Assets -> Open C# Project, as that retriggers fresh .csproj cruft file generation. Close VS first though.
     
    pKallv likes this.
  5. BetrayedPickle

    BetrayedPickle

    Joined:
    Mar 30, 2019
    Posts:
    119
    That didn't work either :/ Hopefully someone else has a solution.
     
  6. Trellace

    Trellace

    Joined:
    Feb 19, 2020
    Posts:
    1
    I know this is an older forum but I finally figured this out myself. I was using VS Code, as had the same issue where UnityEngine.UI wasn't working. This is what fixed it for me:
    1) Switch from VS Code to VS Community as script editor
    2) Regenerate .csproj files
    3) Open a script to see if the issues are fixed. You can keep using Community or to switch back to VS Code do as follows
    4) If the scripts work, repeat the process of switching editor and regenerating .csproj files but with VS Code
    5) Should now be fine
    When I reopened my scripts in VS Code, the errors reappeared but the scripts still worked fine. The number of errors actually doubled. However, it worked, so I'm not to fussed. Hope this works for you.
     
  7. BetrayedPickle

    BetrayedPickle

    Joined:
    Mar 30, 2019
    Posts:
    119
    I actually uninstalled unity and visual studio and unity hub (basically everything related to unity) and now my game is working just fine with the UI
     
    joachimbose48 likes this.
  8. guiffen

    guiffen

    Joined:
    Mar 17, 2013
    Posts:
    10
    Logged in merely to say thank you. This worked perfectly!
     
  9. Ahsan44

    Ahsan44

    Joined:
    Nov 19, 2019
    Posts:
    2
     
  10. Amey_Gamersroof

    Amey_Gamersroof

    Joined:
    May 27, 2021
    Posts:
    1
    This worked for me. Huge thanks!!!
     
  11. pKallv

    pKallv

    Joined:
    Mar 2, 2014
    Posts:
    1,128
    This worked for me too, thanks m8.
     
  12. pKallv

    pKallv

    Joined:
    Mar 2, 2014
    Posts:
    1,128
    hmmm it came back
     
    Roman_Keivan likes this.
  13. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,762
    Unity / VS may do this every time you add a new file.

    Or maybe just because it's time to flake out again.

    But all the steps above should still fix. If they don't, I got nothing more; maybe someone else does?

    (See my updated post refreshed today)
     
    pKallv likes this.
  14. ASDF_alpha

    ASDF_alpha

    Joined:
    Aug 25, 2020
    Posts:
    28
    I have the same problem upload_2021-8-12_16-5-47.png
     
    ehsan_wwe1 likes this.
  15. tggirl

    tggirl

    Joined:
    Aug 7, 2020
    Posts:
    2
    Insted of:

    using Unity.UI; try this: using UnityEngine.UI;
     
  16. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,741
    Literally no one in this thread was using Unity.UI
     
    Vickey_Soni and Kurt-Dekker like this.
  17. WASDev

    WASDev

    Joined:
    Dec 6, 2020
    Posts:
    1
    If all else failed, try this.

    1) Switch to VS Community under External Script Editor.
    2) Regenerate project files
    3) Switch back to VS Code.
    4) DON'T regenerate project files.
    5) Restart everything.
     
  18. amyyazdan

    amyyazdan

    Joined:
    May 4, 2021
    Posts:
    1
    Many thanks to you, After I tried all those replies in "unity forum" and "stackoverflow", Only you helped me!
     
  19. CTN-Originals

    CTN-Originals

    Joined:
    May 30, 2020
    Posts:
    6
    Yup, this also worked for me!
    You must have gone real desperate to find this out yourself. Thanks man :D
     
  20. DankeMart

    DankeMart

    Joined:
    Mar 19, 2022
    Posts:
    1
    Thank you very much, it still works!
     
  21. Roman_Keivan

    Roman_Keivan

    Joined:
    May 31, 2019
    Posts:
    21
    Thank you Sir, It's Helped to me :) ;)
     
Thread Status:
Not open for further replies.