Performance: Background music management
MEDIUM IMPACT
This concept affects the game's frame rate and load times by managing audio playback efficiently.
void Start() {
audioSource.Play();
}void Update() {
if (!audioSource.isPlaying) {
audioSource.Play();
}
}| Pattern | CPU Usage | Frame Drops | Audio Quality | Verdict |
|---|---|---|---|---|
| Repeated Play calls in Update | High (checks every frame) | Frequent | Audio glitches | [X] Bad |
| Play music once at Start | Low (single call) | None | Smooth playback | [OK] Good |
| Load audio at runtime | High (blocking load) | Severe | Possible stutter | [X] Bad |
| Preload audio in Awake | Low (preload once) | None | Smooth playback | [OK] Good |
| Abrupt music switch | Low | None | Audio pops | [!] OK |
| Fade music switch | Low (small overhead) | None | Smooth transition | [OK] Good |