Unity CC0 sound effects & 2D VFX setup
1. AudioImporter preset matrix
Importing short 44,100 Hz 16-bit mono WAV files with Unity’s default Vorbis / Quality 100 introduces unnecessary CPU decode overhead on rapid gunfire and UI clicks. Match AudioImporter settings to clip length instead:
| Clip length | Load Type | Compression Format | Force To Mono | Preload Audio Data |
|---|---|---|---|---|
| Short SFX (< 0.6 s: clicks, hits, coins, shots) | Decompress On Load | PCM or ADPCM | Checked | Checked |
| Medium SFX (0.6–2.5 s: explosions, jingles) | Compressed In Memory | ADPCM | Checked | Checked |
Seamless loops (rain-loop, wind-loop) |
Compressed In Memory | Vorbis (Quality 70%) | Checked | Checked |
2. Prevent pitch-sharing bugs on PlayOneShot
Mutating audioSource.pitch right before calling PlayOneShot(clip) on a single shared AudioSource bends the pitch of every explosion or jingle tail still playing on that component. Rotate across a ring buffer of 8 lightweight AudioSource components instead:
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Audio;
public class PixelFxSfxPool : MonoBehaviour
{
[SerializeField] private AudioMixerGroup sfxGroup;
[SerializeField] private int poolSize = 8;
private AudioSource[] _pool;
private int _cursor;
private readonly Dictionary<string, float> _lastTrigger = new();
private void Awake()
{
_pool = new AudioSource[poolSize];
for (int i = 0; i < poolSize; i++)
{
var src = gameObject.AddComponent<AudioSource>();
src.playOnAwake = false;
src.spatialBlend = 0f;
src.outputAudioMixerGroup = sfxGroup;
_pool[i] = src;
}
}
public void PlayRandomTake(string key, AudioClip[] takes, float cooldownSec = 0.035f, float pitchSpread = 0.04f)
{
if (takes == null || takes.Length == 0) return;
float now = Time.unscaledTime;
if (_lastTrigger.TryGetValue(key, out float prev) && now - prev < cooldownSec)
return;
_lastTrigger[key] = now;
AudioSource src = _pool[_cursor];
_cursor = (_cursor + 1) % _pool.Length;
src.pitch = 1f + Random.Range(-pitchSpread, pitchSpread);
src.PlayOneShot(takes[Random.Range(0, takes.Length)], 0.9f);
}
}
3. AudioMixer ducking & 2D Animation Event sync
Because PixelFx SFX Studio categories are loudness-matched relative to each other (ui at -20 LUFS, pickup and shoot at -16 LUFS, explosion at -14 LUFS), leave initial AudioMixerGroup faders at 0 dB. Add a Duck Volume insert on your Music group fed by a Send from Explosions or Jingles (Threshold -18 dB, Ratio 3:1, Attack 20 ms, Release 280 ms).
To lock audio transients to sliced sprite frames from Hit & impact or Unity 2D Pixel VFX, place an Animation Event on the exact impact keyframe calling PlayRandomTake("hit", hitTakes). Every exported ZIP also includes manifest.json with exact durationSec, peakDb, and loop metadata for automated Editor asset postprocessors.