一键导入
audio
Unity audio system — AudioMixer groups, snapshots, spatial audio, audio source pooling, compression per platform.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Unity audio system — AudioMixer groups, snapshots, spatial audio, audio source pooling, compression per platform.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
DOTween animation library — sequence composition, tween lifecycle, easing, kill strategies. CRITICAL: Always kill tweens in OnDestroy to prevent leaks and errors.
Dialogue tree patterns — ScriptableObject graph, node types (text, choice, condition, event), typewriter effect, localization-ready. Load when implementing NPC conversations.
Generic state machine patterns — IState interface, StateMachine<T>, game state management (menu/gameplay/pause), enemy AI states, hierarchical FSM. Load when implementing state-driven behavior.
2D platformer architecture — tight controls (coyote time, input buffer, variable jump), level design patterns, collectibles, checkpoints, hazards, boss patterns.
Unity physics — non-allocating queries, collision layers, FixedUpdate discipline, continuous collision detection, character controllers, joints.
How the atomic instinct learning system works — observations, distillation, confidence scoring, project vs global scope, and promotion/evolution workflows.
| name | audio |
| description | Unity audio system — AudioMixer groups, snapshots, spatial audio, audio source pooling, compression per platform. |
| globs | ["**/*.mixer","**/*Audio*.cs","**/*Sound*.cs","**/*Music*.cs"] |
Master (exposed: "MasterVolume")
├── Music (exposed: "MusicVolume")
├── SFX (exposed: "SFXVolume")
│ ├── Weapons
│ ├── Environment
│ └── UI
└── Voice (exposed: "VoiceVolume")
[SerializeField] private AudioMixer _mixer;
public void SetMasterVolume(float normalizedValue)
{
// Convert 0-1 slider to decibels (-80 to 0)
float dB = normalizedValue > 0.001f
? Mathf.Log10(normalizedValue) * 20f
: -80f;
_mixer.SetFloat("MasterVolume", dB);
}
// Transition between snapshots for ambient changes
_underwaterSnapshot.TransitionTo(0.5f); // Muffle audio underwater
_defaultSnapshot.TransitionTo(1.0f); // Return to normal
// One-shot SFX (fire and forget, doesn't interrupt)
_audioSource.PlayOneShot(_explosionClip, 0.8f);
// Music (interruptible, one at a time per source)
_musicSource.clip = _battleMusic;
_musicSource.Play();
public sealed class SFXPool : MonoBehaviour
{
[SerializeField] private int _poolSize = 16;
[SerializeField] private AudioMixerGroup _sfxGroup;
private AudioSource[] _sources;
private int _nextIndex;
private void Awake()
{
_sources = new AudioSource[_poolSize];
for (int i = 0; i < _poolSize; i++)
{
GameObject obj = new GameObject($"SFX_{i}");
obj.transform.SetParent(transform);
AudioSource source = obj.AddComponent<AudioSource>();
source.outputAudioMixerGroup = _sfxGroup;
source.playOnAwake = false;
_sources[i] = source;
}
}
public void PlayAt(AudioClip clip, Vector3 position, float volume = 1f)
{
AudioSource source = _sources[_nextIndex];
_nextIndex = (_nextIndex + 1) % _poolSize;
source.transform.position = position;
source.spatialBlend = 1f; // 3D
source.PlayOneShot(clip, volume);
}
}
spatialBlend: 0 = 2D (UI, music), 1 = 3D (world SFX)minDistance: full volume radiusmaxDistance: silence radiusrolloffMode: Logarithmic (realistic) or Custom (AnimationCurve)spread: 0 = point source, 360 = omnidirectional| Type | Format | Load Type | Use |
|---|---|---|---|
| Music | Vorbis (quality 40-60%) | Streaming | Background music |
| SFX (short) | ADPCM | Decompress On Load | Gunshots, jumps |
| SFX (long) | Vorbis (quality 70%) | Compressed In Memory | Ambient loops |
| UI | PCM (uncompressed) | Decompress On Load | Button clicks |
public sealed class MusicManager : MonoBehaviour
{
[SerializeField] private AudioSource _sourceA;
[SerializeField] private AudioSource _sourceB;
[SerializeField] private float _crossfadeDuration = 2f;
private AudioSource _activeSource;
public void CrossfadeTo(AudioClip newClip)
{
AudioSource incoming = _activeSource == _sourceA ? _sourceB : _sourceA;
incoming.clip = newClip;
incoming.volume = 0f;
incoming.Play();
StartCoroutine(Crossfade(_activeSource, incoming));
_activeSource = incoming;
}
private IEnumerator Crossfade(AudioSource outgoing, AudioSource incoming)
{
float elapsed = 0f;
while (elapsed < _crossfadeDuration)
{
elapsed += Time.unscaledDeltaTime;
float t = elapsed / _crossfadeDuration;
outgoing.volume = 1f - t;
incoming.volume = t;
yield return null;
}
outgoing.Stop();
}
}
AudioListener per scene (usually on the camera)Time.unscaledDeltaTime for audio during pause