Consider this Unity C# script snippet using TextMeshPro. What text will appear on the screen?
using TMPro; using UnityEngine; public class TMPExample : MonoBehaviour { public TMP_Text tmpText; void Start() { tmpText.text = "Score: " + (10 + 5); } }
Remember how string concatenation works with numbers in C#.
The expression "Score: " + 10 + 5 concatenates from left to right. "Score: " + 10 becomes "Score: 10" (string), then + 5 becomes "Score: 105" (string).
You want to display text that changes often and supports rich styling like bold, italic, and color. Which Unity component should you use?
Think about which component supports advanced text features and performance.
TextMeshProUGUI supports rich text styling, dynamic updates, and better quality rendering than the basic UI Text component.
Look at this code snippet. The text does not change on screen after calling UpdateScore. What is the problem?
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; } }
Check variable shadowing inside UpdateScore.
Inside UpdateScore, the line 'TMP_Text scoreText = GetComponent
Choose the code that correctly sets the color of a TextMeshProUGUI text component to red.
Check the official property name for color in TextMeshProUGUI.
The correct property to change text color is 'color'. Methods like SetColor or properties like textColor do not exist in TextMeshProUGUI.
Given this code, how many visible characters will the TextMeshProUGUI component display?
using TMPro; using UnityEngine; public class TextCount : MonoBehaviour { public TMP_Text tmpText; void Start() { tmpText.text = "Hello <color=red>World</color>!"; } }
Count only visible characters, ignoring tags.
The string "Hello