Builds and performance
Profile before optimizing; ship a build that runs on the target device.
What you will be able to do
- Profile one real scene before changing settings.
- Avoid Instantiate/Destroy in hot loops; pool objects.
- Check the target platform’s memory and input constraints.
In plain English
Use the Profiler to find CPU and GPU cost. Reduce draw calls with batching, avoid per-frame allocations and use object pooling for repeated spawns. Test the actual build on the target hardware, not only in the editor.
using System.Collections.Generic;
using UnityEngine;
public class Pool : MonoBehaviour
{
[SerializeField] private GameObject prefab;
private readonly Queue<GameObject> available = new();
public GameObject Get()
{
if (available.Count > 0) return available.Dequeue();
return Instantiate(prefab);
}
public void Return(GameObject item)
{
item.SetActive(false);
available.Enqueue(item);
}
}Your turn
MediumBuild a simple pool
Implement Get and Return for a prefab, reusing inactive objects.
CSHARP · starter
public GameObject Get() {}Check your understanding before moving on.
Knowledge checkQuestion 1
Why use object pooling?
Select an answer to continue
Study tools
Make it yours.
Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.
Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign inFinished reading?
Lock in what you just learned.
0%
Mark this lesson complete to save your place and move one step closer to the certificate.