05. Unassigned Reference Exception
🟡 Runtime / Inspector Error
You declared a public or [SerializeField] variable and Unity is calling it — but you forgot to drag-and-drop the reference in the Inspector. It’s basically a Null but Unity gives you a more specific message.
UnassignedReferenceException: The variable spawnPoint of SpawnManager has not been assigned.You probably need to assign the spawnPoint variable of the SpawnManager script in the inspector. SpawnManager.SpawnEnemy () (at Assets/Scripts/SpawnManager.cs:19)
- Select the GameObject in the Hierarchy that has this script.
- In the Inspector, find the script component.
- Look for the empty field (shown as “None (Transform)” or similar).
- Drag the correct GameObject or Component into that field.
💡 Pro Tip
UseÂ[RequireComponent(typeof(Rigidbody))] above your class to force Unity to auto-attach required components — preventing this class of error entirely.