0
0
Unityframework~20 mins

Text and TextMeshPro in Unity - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
TextMeshPro Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this TextMeshPro code?

Consider this Unity C# script snippet using TextMeshPro. What text will appear on the screen?

Unity
using TMPro;
using UnityEngine;

public class TMPExample : MonoBehaviour {
    public TMP_Text tmpText;

    void Start() {
        tmpText.text = "Score: " + (10 + 5);
    }
}
AScore: 15
BScore: 10 5
CScore: 105
DScore: 10+5
Attempts:
2 left
💡 Hint

Remember how string concatenation works with numbers in C#.

🧠 Conceptual
intermediate
1:30remaining
Which component is best for dynamic styled text in Unity?

You want to display text that changes often and supports rich styling like bold, italic, and color. Which Unity component should you use?

AUnityEngine.UI.Text
BTextMeshProUGUI
CRawImage
DCanvasRenderer
Attempts:
2 left
💡 Hint

Think about which component supports advanced text features and performance.

🔧 Debug
advanced
2:30remaining
Why does this TextMeshPro text not update?

Look at this code snippet. The text does not change on screen after calling UpdateScore. What is the problem?

Unity
using TMPro;
using UnityEngine;

public class ScoreDisplay : MonoBehaviour {
    public TMP_Text scoreText;
    private int score = 0;

    void Start() {
        UpdateScore();
    }

    public void AddPoints(int points) {
        score += points;
        UpdateScore();
    }

    void UpdateScore() {
        TMP_Text scoreText = GetComponent<TMP_Text>();
        scoreText.text = "Score: " + score;
    }
}
AThe AddPoints method is never called, so UpdateScore is never triggered.
BThe score variable is never updated, so the text stays at zero.
CThe TMP_Text component is missing from the GameObject, causing a null reference.
DThe UpdateScore method creates a new local scoreText hiding the public one, so the displayed text never changes.
Attempts:
2 left
💡 Hint

Check variable shadowing inside UpdateScore.

📝 Syntax
advanced
1:30remaining
Which code snippet correctly changes TextMeshPro text color?

Choose the code that correctly sets the color of a TextMeshProUGUI text component to red.

AtmpText.textColor = Color.red;
BtmpText.SetColor(Color.red);
CtmpText.color = Color.red;
DtmpText.SetTextColor(Color.red);
Attempts:
2 left
💡 Hint

Check the official property name for color in TextMeshProUGUI.

🚀 Application
expert
2:30remaining
How many characters will be displayed after this TextMeshPro update?

Given this code, how many visible characters will the TextMeshProUGUI component display?

Unity
using TMPro;
using UnityEngine;

public class TextCount : MonoBehaviour {
    public TMP_Text tmpText;

    void Start() {
        tmpText.text = "Hello <color=red>World</color>!";
    }
}
A12
B11
C10
D13
Attempts:
2 left
💡 Hint

Count only visible characters, ignoring tags.