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

UnityEngine.UI and TMPro stop working

Discussion in 'Scripting' started by abermann_O, Jul 2, 2021.

  1. abermann_O

    abermann_O

    Joined:
    Aug 16, 2018
    Posts:
    42
    Hi,

    I´m getting this error in Unity 2019.3.12f1, with a project that worked fine just few weeks ago. Just to double check, I create a new project from scratch (same error):

    1. New 2D project (Unity 2019.3.12f1)
    2. New C# script (same error in both VS 2019, and VSCode):
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5. using TMPro;
    6.  
    7. public class NewBehaviourScript : MonoBehaviour
    8. {
    9.     Image image;
    10.     TextMeshPro myText;
    11.  
    12.     private void Start()
    13.     {
    14.        
    15.     }
    16. }
    In the Solution Explorer, I can see UnityEngine.UI enabled in the project.
    Screens of the errors (TextMeshPro error is almost identical):

    Untitled-1.jpg

    Any ideas? I already posted a similar error, but without screen prints... so hopefully somebody may have gone through this and found a solution...

    Thanks!
     
  2. RadRedPanda

    RadRedPanda

    Joined:
    May 9, 2018
    Posts:
    1,593
    You have to import TMP from the Package Manager in a new project, it's not included by default.
     
  3. abermann_O

    abermann_O

    Joined:
    Aug 16, 2018
    Posts:
    42
    Thanks, radRedPanda, correct me if I´m wrong, but when I open the Package Manager, what I´m seeing is Text Mesh Pro installed, right? It was like this when I created the project, I never installed it.

    I think the problem is something else, and it must be related to either TextMeshPro or Unity UI (at the bottom of the TMPro package manager window, it says Dependencies: Unity UI (installed).

    Maybe that explains why both packages drop an error?

    upload_2021-7-2_2-20-32.png
     
  4. RadRedPanda

    RadRedPanda

    Joined:
    May 9, 2018
    Posts:
    1,593
    Seems like I was incorrect, sorry about that! I tried it in my 2019.4.3f1 version and it seemed to work fine, so I'm going to try to recreate it in your version.
     
  5. RadRedPanda

    RadRedPanda

    Joined:
    May 9, 2018
    Posts:
    1,593
    Hi, I did some searching on the internet, and this solution might be of interest to you.

    https://stackoverflow.com/a/61067542
     
    abermann_O likes this.
  6. abermann_O

    abermann_O

    Joined:
    Aug 16, 2018
    Posts:
    42
    Thank you very much, RadRedPanda! I´ll give a try to all the solutions proposed in that article, and I´ll let you know
    what happened!
     
  7. RadRedPanda

    RadRedPanda

    Joined:
    May 9, 2018
    Posts:
    1,593
    So I ended up copying your steps, and it seems to be working fine with me, no problems there on my side. It definitely seems like the Projects got messed up or something on your side, so hopefully that solution can fix your problem.
     
    abermann_O likes this.
  8. abermann_O

    abermann_O

    Joined:
    Aug 16, 2018
    Posts:
    42
    Thank you for your time, RadRedPanda! It really helps to know that the problem is related to my local configuration, tomorrow I´ll check step by step the url you sent me. Have a great day!
     
    RadRedPanda likes this.
  9. abermann_O

    abermann_O

    Joined:
    Aug 16, 2018
    Posts:
    42
    Hi, RadRedPanda, I tried all the options of the link you sent to me (excellent information, btw). Unfortunately, none of them worked in my case, so I upgrade the project to the next LTS version (in this case, 2019.4.28) which do recognize all the libraries (UnityEngine.UI and TMPro), and because if was very close to the original one, there were no harm in the process. It would be great to find out what happened, but right now time is the priority, so I´ll move on. Again, thank you very much for your time and all the information you sent me! Have a great day!
     
  10. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,711
    Try closing Unity, then going into your project folder and into the Library folder there in the project, and look for some directory called "package cache", destroy it, then reopen Unity and let it pull all the packages down afresh.
     
    abermann_O likes this.
  11. abermann_O

    abermann_O

    Joined:
    Aug 16, 2018
    Posts:
    42
    Thank you, Kurt-Dekker, unfortunately that doesn´t work... I even tried to delete the whole Library folder, but that doesn´t work either. I´ve must broke something along the road, but have no idea what may be...
     
  12. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,711
    Make a new project, import the modules you want, get it working.

    Now either:

    a) drop the Assets folder from your current project onto the new project and make that your project, or

    b) drop the project settings folder onto your current project and do it that way.

    It's just data, bring the parts together, get it going.

    EITHER WAY DO NOT DO ANYTHING LIKE THE ABOVE UNTIL YOU HAVE YOUR PROJECT FULLY BACKED UP AND/OR UNDER COMPLETE PROPER TESTED AND FUNCTIONING SOURCE CONTROL.
     
  13. staticV01d

    staticV01d

    Joined:
    Apr 26, 2021
    Posts:
    2
  14. Hobby-Game-Developer

    Hobby-Game-Developer

    Joined:
    Aug 27, 2017
    Posts:
    14