Making your first Unity project helps you learn how to create and run a simple game scene. It shows you how to display text on the screen, like saying "Hello World" to start.
First Unity project (Hello World scene)
1. Create a new Unity project. 2. In the Hierarchy, create a UI Text object: GameObject > UI > Text - TextMeshPro. 3. Create a new C# script and attach it to a GameObject. 4. In the script, use: using TMPro; using UnityEngine; public class HelloWorld : MonoBehaviour { public TMP_Text helloText; void Start() { helloText.text = "Hello World!"; } }
You need to have TextMeshPro package installed (usually included by default).
Attach the script to any GameObject in the scene and link the TextMeshPro UI text in the Inspector.
using TMPro; using UnityEngine; public class HelloWorld : MonoBehaviour { public TMP_Text helloText; void Start() { helloText.text = "Hello World!"; } }
// Alternative: Using UnityEngine.UI.Text (older UI system) using UnityEngine; using UnityEngine.UI; public class HelloWorld : MonoBehaviour { public Text helloText; void Start() { helloText.text = "Hello World!"; } }
This complete example shows how to set up a simple Unity scene that displays "Hello World!" using a TextMeshPro UI text and a script.
// HelloWorld.cs using TMPro; using UnityEngine; public class HelloWorld : MonoBehaviour { public TMP_Text helloText; void Start() { helloText.text = "Hello World!"; } } // Steps to run: // 1. Create a new Unity project. // 2. Add a Canvas to the scene (if not present). // 3. Add a TextMeshPro - Text object to the Canvas. // 4. Create this HelloWorld script and attach it to an empty GameObject. // 5. Drag the TextMeshPro text object to the 'helloText' field in the Inspector. // 6. Press Play to see "Hello World!" on the screen.
Make sure to import TextMeshPro essentials if prompted by Unity.
UI elements like TextMeshPro need a Canvas in the scene to be visible.
You can customize the font size, color, and position of the text in the Inspector.
Creating a first Unity project helps you understand scenes, UI, and scripting basics.
Use a TextMeshPro UI text to show messages like "Hello World!" on screen.
Attach scripts to GameObjects and link UI elements to control what they show.