Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

The type or namespace name 'TextMeshProUGUI' could not be found

Discussion in 'Package Manager' started by magg, Aug 6, 2018.

  1. magg

    magg

    Joined:
    Sep 29, 2013
    Posts:
    74
    So after going from 2017.3.1 to 2018.2.1f1 I had to spend 2 days fixing stuff - mostly just related to TMP. Everything was broken so I had to uninstall (delete), install, reinstall and manually fix all my TMP UIs.

    The game is running without any problems now (even builds), but for some odd reason Visual Studio gives me these:
    The type or namespace name 'TextMeshProUGUI' could not be found (are you missing a using directive or an assembly reference?)

    It's everywhere I'm using it like this:
    public TextMeshProUGUI UI_EntryTxtLocation;

    Also VS now says "Using directive is unnecessary" for:
    using TMPro;
    using UnityEngine.Events;
    using UnityEngine.EventSystems;

    Any ideas?
     
    Deepkamal likes this.
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Sorry that you had to invest that time to upgrade to the newer version of TMP. Provided you followed the procedure outlined in the following sticky post as well as reviewed the Update Notes at the bottom of this post, the process should have been pretty quick (with the exception of the scanning process which can take more time depending on the project size).

    In terms of the errors in Visual Studio, this is an issue between Assembly Definitions (which packages happen to use) and Visual Studio / VSTU. The solution is to upgrade to the latest version of Visual Studio 2017 which is 15.7.6. This information is also provided in the Update Notes section of the post I referenced above.

    Let me know if this resolves your issue?
     
  3. magg

    magg

    Joined:
    Sep 29, 2013
    Posts:
    74
    Thanks - that was FAST.

    Reinstalled VS and everything looks a-OK. TY again.
     
    Stephan_B likes this.
  4. MrLucid72

    MrLucid72

    Joined:
    Jan 12, 2016
    Posts:
    962
    Getting this now in VS 15.8.7
    upload_2018-10-23_20-11-45.png

     
  5. hal0000

    hal0000

    Joined:
    Oct 5, 2017
    Posts:
    13
    @Stephan_B yea samething happened to me please check my post.
     
    Yashajain likes this.
  6. Alkanov

    Alkanov

    Joined:
    May 15, 2017
    Posts:
    54
    Same problem here - Unity works fine and no errors found but on the VS project I get the same errors as above screenshot
     
  7. Alkanov

    Alkanov

    Joined:
    May 15, 2017
    Posts:
    54
    Changing the editor from VS to extension and then back to VS solved the problem
     
  8. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Glad to know this worked.

    I'll bring this thread again to the attention of the appropriate folks at Unity as whatever is causing this behavior should be addressed.
     
  9. LeleUnity

    LeleUnity

    Joined:
    Jul 30, 2016
    Posts:
    97
    Hello, I Have 2018.3.7.f1,
    and Both TextMeshPro and Packages Manager do not show in Window. I had a working project in Unity 2017
    LTS, I then updated to this and I have this problem.
    I tried:
    -Help-->Reset Dependencies.
    -deleting cache
    -deleted old TextMeshPro from Asset
    this is the manifest:
    "dependencies": {
    "com.unity.ads": "2.0.8",
    "com.unity.analytics": "3.2.2",
    "com.unity.collab-proxy": "1.2.15",
    "com.unity.package-manager-ui": "2.0.3",
    "com.unity.purchasing": "2.0.3",
    "com.unity.textmeshpro": "1.3.0",
    "com.unity.modules.ai": "1.0.0",
    "com.unity.modules.animation": "1.0.0",
    "com.unity.modules.assetbundle": "1.0.0",
    "com.unity.modules.audio": "1.0.0",
    "com.unity.modules.cloth": "1.0.0",
    "com.unity.modules.director": "1.0.0",
    "com.unity.modules.imageconversion": "1.0.0",
    "com.unity.modules.imgui": "1.0.0",
    "com.unity.modules.jsonserialize": "1.0.0",
    "com.unity.modules.particlesystem": "1.0.0",
    "com.unity.modules.physics": "1.0.0",
    "com.unity.modules.physics2d": "1.0.0",
    "com.unity.modules.screencapture": "1.0.0",
    "com.unity.modules.terrain": "1.0.0",
    "com.unity.modules.terrainphysics": "1.0.0",
    "com.unity.modules.tilemap": "1.0.0",
    "com.unity.modules.ui": "1.0.0",
    "com.unity.modules.uielements": "1.0.0",
    "com.unity.modules.umbra": "1.0.0",
    "com.unity.modules.unityanalytics": "1.0.0",
    "com.unity.modules.unitywebrequest": "1.0.0",
    "com.unity.modules.unitywebrequestassetbundle": "1.0.0",
    "com.unity.modules.unitywebrequestaudio": "1.0.0",
    "com.unity.modules.unitywebrequesttexture": "1.0.0",
    "com.unity.modules.unitywebrequestwww": "1.0.0",
    "com.unity.modules.vehicles": "1.0.0",
    "com.unity.modules.video": "1.0.0",
    "com.unity.modules.vr": "1.0.0",
    "com.unity.modules.wind": "1.0.0",
    "com.unity.modules.xr": "1.0.0"
    }
    }
    PLEASE HELP ME IT'S 5 DAYS I AM Struggling with this !
     
  10. LeleUnity

    LeleUnity

    Joined:
    Jul 30, 2016
    Posts:
    97
    I have done also what you suggested in here. nothing works!
     
  11. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Have you tried both updating Visual Studio to the latest release and changing the External Script Editor?

    If the issue persists, please submit a bug report with the project so that we can have our scripting folks take a look at this so we can resolve this issue once and for all.
     
    LeleUnity likes this.
  12. LeleUnity

    LeleUnity

    Joined:
    Jul 30, 2016
    Posts:
    97
    Yes Ihave done that. No solution.
    How Can I upload a very sensitive project of many gigabytes?
     
  13. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Just use the Help - Report a Bug.

    The includes resources in the report are private and will only be used to resolve the reported issue.
     
  14. hpr895

    hpr895

    Joined:
    Apr 30, 2019
    Posts:
    3
    Hi )

    Try to use this:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5.  
    6. using TMPro; // <= THIS
    7.  
    8. public class Score : MonoBehaviour
    9. {
    10.     public Transform player;
    11.     public TextMeshProUGUI scoreText;
    12.  
    13.     void Update()
    14.     {
    15.         float position = player.position.z;
    16.  
    17.         scoreText.text = position.ToString();
    18.     }
    19. }
    20.  
    You can find it by clicking on the Text Mesh Pro UGUI with right mouse button, then "Edit script", then just copy class namespace in using section of your class.
     
    Last edited: May 21, 2019
  15. Twinsens

    Twinsens

    Joined:
    Dec 27, 2018
    Posts:
    6
    Same here. But i was solve this issue with these steps,

    Window / Package Manager find the 'Text Mesh Pro' then click remove. After remove complete, click install again.
     
  16. IvayloDev

    IvayloDev

    Joined:
    Apr 20, 2015
    Posts:
    23
    Thanks, That seems to be the only way to fix this anomaly... for some reason it happens way too often I before this fix I had to reimport all which takes like 30 minutes..
     
  17. Altanin

    Altanin

    Joined:
    Jul 21, 2020
    Posts:
    15
    SAME PROB


    error CS0246: The type or namespace name 'textMeshProUGUI' could not be found (are you missing a using directive or an assembly reference?)
     
  18. altepTest

    altepTest

    Joined:
    Jul 5, 2012
    Posts:
    1,104
    I've had issues with Text Mesh Pro and Doozy Ui and this may be related. Basically if you use an assets that require TextMeshPro but you didn't use it TextMeshPro directly before installing that package you will get errors.

    That because TextMeshPro needs to import some additional stuff when first used but the import window will not fire if other assets use textmeshpro they just assume textmeshpro will work

    When creating a new project before installing any other asset I will create in the scene hierarchy a button or text that use textmeshpro then wait for the first time assets to be imported then delete that canvas with the button.
     
  19. kirk717

    kirk717

    Joined:
    Sep 26, 2020
    Posts:
    1
    Hi, it is case sensitive, should be upper case "T", TextMeshProUGUI
     
  20. Altanin

    Altanin

    Joined:
    Jul 21, 2020
    Posts:
    15
    thankyoou!
     
  21. Mizhael

    Mizhael

    Joined:
    Jul 15, 2015
    Posts:
    5
    i got the problem that is not even detecting the dll

    upload_2021-5-27_0-6-58.png

    i try to remove it from package manager and add it back, but it seems it does not work

    does anyone faced this before?
     
  22. UnityMaru

    UnityMaru

    Community Engagement Manager PSM

    Joined:
    Mar 16, 2016
    Posts:
    1,227
    Is there anything in the error console?
     
  23. Mizhael

    Mizhael

    Joined:
    Jul 15, 2015
    Posts:
    5
    hi, thanks for replying, in the matter of fact yes, i do noticed that the increase of errors are more now yesterday i was trying to check which dlls i have in my project folder of \Library\ScriptAssemblies and also if these missing dlls are in C:\Program Files\Unity\Hub\Editor\2020.3.9f1\Editor\Data\Managed\UnityEngine

    below is the errors in the console.

    upload_2021-5-27_12-41-28.png
     
  24. colossalnate

    colossalnate

    Joined:
    Jun 19, 2021
    Posts:
    5
    im having the same problem, i am new to coding and im following along with a tutorial to help me get a grip but when i went to test my bulldoze i got a few errors, i managed to fix all but this one and i cant tell why this is showing up here is my code if it helps
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class City : MonoBehaviour
    6. {
    7.     public int money;
    8.     public int day;
    9.     public int curPopulation;
    10.     public int curJobs;
    11.     public int curFood;
    12.     public int maxPopulation;
    13.     public int maxJobs;
    14.     public int incomePerJob;
    15.  
    16.     public TextMeshProUGUI statsText;
    17.  
    18.     public List<Building> buildings = new List<Building>();
    19.  
    20.     public static City instance;
    21.  
    22.     void awake()
    23.     {
    24.         instance = this;
    25.     }
    26.  
    27.    public void OnePlaceBuilding (Building building)
    28.     {
    29.         money -= building.preset.cost;
    30.         MaxPopulation += building.preset.population;
    31.         maxJobs += building.preset.jobs;
    32.         buildings.Add(building);
    33.  
    34.         UpdateStatText();
    35.     }
    36.  
    37.     public void OnRemoveBuilding (Building building)
    38.     {
    39.         MaxPopulation -= building.preset.population;
    40.         maxJobs -= building.preset.jobs;
    41.         buildings.Remove(building);
    42.         Destroy(building.GameObject);
    43.  
    44.         UpdateStatText();
    45.     }
    46.  
    47.     void UpdateStatText()
    48.     {
    49.  
    50.     }
    51. }
     
  25. What's the error?

    Next time please open your own thread. Hijacking old threads is very bad.
     
  26. colossalnate

    colossalnate

    Joined:
    Jun 19, 2021
    Posts:
    5
    2 things: one, sorry about hijacking, i saw the last post was from a month ago so i assumed it was ok to post, and 2, the error the thread is about "The type or namespace name 'TextMeshProUGUI' could not be found
     
  27. You are missing the
    using TMPro;
    statement at the beginning of your file.
     
    cwhale89 likes this.
  28. rhoster

    rhoster

    Joined:
    Jun 3, 2021
    Posts:
    11
    I'm having a related problem with TMPro and dependencies, although in a somewhat different configuration. I have a custom package (let's call it ExampleFramework) that serves as the baseline framework for my Unity projects. I have the .asmdef and package.json set up properly, and have added it via the Package Manager as a local package - everything is working as expected. However, I've decided to move away from TextMesh and move to TextMeshPro; I do all my scripting inside ExampleFramework, so I need to set TMPro as a dependency there, otherwise my code fails compilation as it can't find the
    Code (CSharp):
    1. TextMeshPro
    class or use the namespace
    Code (CSharp):
    1. using TMPro;
    .

    I've tried adding TMPro as a dependency in my package.json:

    Code (CSharp):
    1. "dependencies": {
    2.       "com.unity.textmeshpro": "3.0.6"
    3.   },
    However this doesn't work. Can anyone please point me to a thread (tried searching a bunch but haven't found one with this question) or help answer how to add a dependency to TMPro to a custom package?
     
  29. The
    Code (CSharp):
    1. "dependencies": {
    2.   "com.unity.textmeshpro": "3.0.6"
    3. },
    should work.

    Besides that, you need to add the
    Unity.TextMeshPro
    dependency to your assembly definition file as well. In the "Assembly Definition References" section.

    After that you can use the
    using TMPro;
    statement.
     
    DenisVelinov and rhoster like this.
  30. rhoster

    rhoster

    Joined:
    Jun 3, 2021
    Posts:
    11
    Thank you so much Lurking-Ninja!! I had tried using "TMPro.TextMeshPro" in the references section (which didn't work). After switching to
    Unity.TextMeshPro
    it worked.

    Was curious where this came from and dug around. Looks like it's defined in
    Unity.TextMeshPro.asmdef
    where
    Code (CSharp):
    1. {
    2.     "name": "Unity.TextMeshPro",
    3.     "references": [],
    4.     "optionalUnityReferences": [],
    5.     "includePlatforms": [],
    6.     "excludePlatforms": [],
    7.     "allowUnsafeCode": false,
    8.     "overrideReferences": false,
    9.     "precompiledReferences": [],
    10.     "autoReferenced": true,
    11.     "defineConstraints": []
    12. }
     
  31. Yes, this is how you define dependencies in assemblies using assembly definition files.

    The easiest way is to add a new line to the references, hit the circle button and type:
    screenshot1.png
     
    supita_unity and rhoster like this.
  32. rhoster

    rhoster

    Joined:
    Jun 3, 2021
    Posts:
    11
    This is a great solution for adding the References. Is there a similar approach for adding dependencies through a typeahead to
    package.json
    ? I looked in the editor and it seems to just take a key/value pair (which works, but curious if I am doing it in a less efficient way).
     
  33. Not that I know of.
     
  34. Acreates

    Acreates

    Joined:
    Dec 12, 2016
    Posts:
    41
    2023 here, all this works on one machine, same editor version, different machine. Something is getting lost when a project is setup.
     
  35. xdaxda077

    xdaxda077

    Joined:
    Aug 20, 2023
    Posts:
    2
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.UI;
    using TMPro;

    public class GameManager : MonoBehaviour
    {
    public int Money;
    public TextMeshProUGIU moneyText;

    public static GameManager instance;

    void Awake()
    {
    instance = this;
    }

    public void AddMoney(int amount)
    {
    money += amount;
    moneyText.text = "$" + Money.ToString();
    }
    public void Takemoney(int amount)
    {
    money -= amount;
    moneyText.text = "$" + Money.ToString();
    }
    }
    help i get Assets\Scripts\GameManager.cs(10,12): error CS0246: The type or namespace name 'TextMeshProUGIU' could not be found (are you missing a using directive or an assembly reference?)
     
  36. xdaxda077

    xdaxda077

    Joined:
    Aug 20, 2023
    Posts:
    2
    studio 2019
     
  37. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,883
    You've made a typo. It's supposed to be
    TextMeshProUGUI
    .
     
    MrLucid72 likes this.
  38. MrLucid72

    MrLucid72

    Joined:
    Jan 12, 2016
    Posts:
    962
    Nice catch. I also get it. I typo'd it so many times, it's wild -- not sure who would name something that difficult that's used so constantly. I wish they just used TextMeshPro namespace then call it TMPTxt or something simple. Unnecessary marketing/branding.

    I personally just type `ugui` and accept my IDE's auto-suggest.
     
  39. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,883
    There is a differently named text renderer for UI Toolkit but I don't think it'll be backported to Unity UI.

    https://forum.unity.com/threads/feedback-wanted-new-text-engine.1007585/