"using TMPro" doesn't work

Hi,

“using TMPro” has dotted red lines, and no such thing as “TextMeshProUGUI” is available among the suggestions as a result - meaning, I have the exact same problem as listed here:

Only, the solution posted on that link is not working for me. Default external script editor is set to VS Code, I tried closing unity and VS code and deleting all cspro and sln files from my project folder, but the problem persists (the cspro and sln files are just regenerated on launch). I also tried removing the whole TMPro package and re-installing, with no luck. Help needed.

When you create a new script does it still show it as an issue? Or is it for that particular project/script?

Hi, I tried creating a new script, but the problem is the same

Hi kolique,

Did you add the TMPro namespace to the top of your script? Remember you can also look at the lecture code changes via the link in the Resources of each lecture.

Hi,

yes, I put “using TMPro;” at the top. I looked through the lecture changes, and don’t see anything different. Some of the code within the main class I haven’t gotten to yet, because I am stuck on the preceding step.

I will attach screenshots of the script file, the preference → external tool editor, the package manager and my project structure.




1 Like

Try to click on “Regenerate project files” (see your first screenshot). If that didn’t help, check the Console in VS Code. Maybe there is a helpful message mentioning if something is missing or suggesting something.

Hello again,

regenerating project files didn’t work.

I have attached a screenshot of the console window

Have you tried to uninstall and reinstall TMP? If so, please follow the instruction on this website and make sure all required extensions are installed: https://code.visualstudio.com/docs/other/unity

If the issue persists, please check the console of VS Code (not Unity!). If the .NET Framework 4.7.1 (Developer Pack) is mentioned there, download and install it from the official Microsoft. Here is the link: https://dotnet.microsoft.com/download/dotnet-framework/net471

Depending on your version of Unity, it might be that you will have to install the “Visual Studio Code Editor” package in Window > Package Manager in Unity.

Maybe you’ll have to reboot your computer. Then launch Unity again and open one of your scripts.

Yes, I tried un- and reinstalling TMP.

I already have the Visual Studio Code Editor package installed.

I already had dotnet 4.7.1 installed, but tried clicking “repair” - no change.

I didn’t have all of the extensions mentioned on that link installed, but I have done so now, and after a reboot the problem remains the same.


Maybe you could try this:

This is a really odd error and Nina has already gone through more with you than I would have thought to check. If what Nina just suggested doesn’t work, all I have is something that probably shouldn’t help, but it’s a hail mary you just never know, it help your situation:

In Visual Studio Code, press CTRL+Shift+P
You want to search for Omnisharp Select Project (and then select the current project)
Then Ctrl-Shift-P and you then want Omnisharp Restart Omnisharp.

From what I read, Visual studio code can occasionally lose what project it’s in and this was some obscure fix I found on the internet that has helped me, my wife and a couple of others. It might not work for you, but I figure, you’re willing to try anything right about now just in case it might work.

Hi, unfortunately it is still not working

Nina → I had a look at the video, and in my Omnisharp log everything loads in successfully, but I went to look at my .net installations, and saw that I had multiple versions installed, so I have deleted everything .net related and then re-installed only 4.7.1. No luck. I also went into extension settings for C# and saw that it was set to auto as default, so changed it to always, but still the problem persists. I restarted my PC in between to make sure.

MichaelIP → thank you for weighing in. I followed your guide and selected the specific project and restarted Omnisharp, but the problem remains the same. Also, Omnisharp seems to load in correctly across the board.

Question: If I were to completely delete everything Unity and VS Code related, and then re-install it all, would there be a risk that all the projects I made so far would somehow be damaged or unable to load? Because I guess that’s my only option at this point?

There’s always a risk, but the risk is very minute. In your case, I’d be surprised if the risk is even that high.

Even if it did happen, you’ll still be able to recover after a bit of pruning in your project directory. At the absolute worst case, you can make a new project and copy and paste the assets/code into the new directory, link up a few things that didn’t transfer over right and you’ll be good to go.

Do make a backup of your project just in case.

I do have an idea for you before you start from scratch. (Back it up first). Close your project. Go into your project directory and delete the Library directory and go and reload the project from UnityHub.

If that doesn’t work, try deleting all the directories except the Assets directory. Load up the project again from UnityHub and cross your fingers. It’ll recompile everything and maybe the issue will have disappeared. You might have a bunch of things you’ll need to fix in your project, but it might be worth trying.

If I were to completely delete everything Unity and VS Code related, and then re-install it all, would there be a risk that all the projects I made so far would somehow be damaged or unable to load? Because I guess that’s my only option at this point?

Michael already answered these questions, so I don’t want to repeat what he wrote. I just want to add the following: If VS Code does not work (well), don’t waste your time with it anymore. Instead, install Visual Studio Community Edition. Then select it as your External Script Editor in Unity (Edit > Preferences > External Tools). In the Package Manager, make sure the Visual Studio Editor package is installed.

Curious if you found any solutions, currently I’m struggling with the same issue. It is a bummer to say the least. Wondering if uninstalling and reinstalling helped you? Not going to do it if it didn’t seem to work :frowning: Hope you figured it out for your sake, and, well, mine too. Thanks.

Nina, thank you very much, switching to the community edition was a very good advice!

Also, thank you @MichaelP for trying to help, but I didn’t even go through your last guide, it just felt too overwhelming xD

@PearBear → See Nina’s solution, this worked for me

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms