Learning about programming for the first time and would like to know why “magic numbers” are bad particularly in Unity?
It’s not Unity, it’s programming as a whole. I’m assuming by ‘magic number’ you mean predefined constant in code, by the way.
The reason they are bad is because fixing them requires you to rebuild the whole code project, which then requires Unity to rebuild any assets referencing the code. If you store it as a modifiable variable, though, then you can change it in the editor with no lag, significantly improving development iteration speed, especially in balance/polish passes. It also allows game designers to work on balance without knowing how to code.
And, if you have published your game, and need to publish an update, then changing these becomes much harder than if they weren’t defined in code.