Search Unity

Bug I have an error with TMP

Discussion in 'UGUI & TextMesh Pro' started by Shrek35, Feb 18, 2024.

  1. Shrek35

    Shrek35

    Joined:
    Feb 7, 2024
    Posts:
    1
    Assets\scripts\Dialogue\DialogueManager.cs(8,12): error CS0246: The type or namespace name 'TextMeshProUGUI' could not be found (are you missing a using directive or an assembly reference?)

    Assets\scripts\Dialogue\DialogueManager.cs(9,12): error CS0246: The type or namespace name 'TextMeshProUGUI' could not be found (are you missing a using directive or an assembly reference?

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5.  
    6. public class DialogueManager : MonoBehaviour
    7. {
    8.     public TextMeshProUGUI dialogueText;
    9.     public TextMeshProUGUI nameText;
    10.  
    11.     public Animator boxAnim;
    12.     public Animator startAnim;
    13.  
    14.     public Queue<string> sentences;
    15.  
    16.     private void Start(){
    17.         sentences = new Queue<string>();
    18.     }
    19.  
    20.     public void StartDialogue(Dialogue dialogue)
    21.     {
    22.         boxAnim.SetBool("boxOpen", true);
    23.         startAnim.SetBool("startOpen", false);
    24.  
    25.         nameText.text = dialogue.name;
    26.         sentences.Clear();
    27.  
    28.         foreach(string sentence in dialogue.sentences)
    29.         {
    30.             sentences.Enqueue(sentence);
    31.         }
    32.         DisplayNextSentense();
    33.     }
    34.  
    35.     public void DisplayNextSentense()
    36.     {
    37.         if(sentences.Count == 0)
    38.         {
    39.             EndDialogue();
    40.             return;
    41.         }
    42.         string sentence = sentences.Dequeue();
    43.         StopAllCoroutines();
    44.         StartCoroutine(TypeSentence(sentence));
    45.     }
    46.  
    47.     IEnumerator TypeSentence(string sentence)
    48.     {
    49.         dialogueText.text = "";
    50.         foreach(char letter in sentence.ToCharArray())
    51.         {
    52.             dialogueText.text += letter;
    53.             yield return null;
    54.         }
    55.     }
    56.  
    57.     public void EndDialogue()
    58.     {
    59.         boxAnim.SetBool("boxOpen", false);
    60.     }
    61. }
     
  2. sildeflask

    sildeflask

    Joined:
    Aug 16, 2023
    Posts:
    329
    using TMPro;
     
    bugfinders and CodeRonnie like this.
  3. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,428
    This is a post you should ask on the UGUI/TMP forum, not the 2D forum. I'll move your thread there and remove the 2D physics tag too.

    Thanks.