Performance: First Unity project (Hello World scene)
LOW IMPACT
This affects the initial load time and rendering speed of the Unity scene, impacting how quickly the user sees the Hello World message.
using UnityEngine; using UnityEngine.UI; public class HelloWorld : MonoBehaviour { public Text helloText; void Start() { helloText.text = "Hello World"; } }
using UnityEngine; public class HelloWorld : MonoBehaviour { void Start() { for (int i = 0; i < 1000; i++) { GameObject textObj = new GameObject("Text" + i); var text = textObj.AddComponent<UnityEngine.UI.Text>(); text.text = "Hello World"; } } }
| Pattern | GameObjects Created | Reflows | CPU Usage | Verdict |
|---|---|---|---|---|
| Creating 1000 UI Text objects | 1000 | 1000 | High | [X] Bad |
| Using one UI Text object and updating text | 1 | 1 | Low | [OK] Good |