feat: implement audio object definitions and refactor audio system

- Add AudioObjectDefinitions.cs with name-to-ID mappings and ambiguity detection
- Update AudioSystem.cs to support Play(uint) and deprecated Play(string) with warnings
- Rename PitchStepManager to PitchStepResolver and update all references
- Refactor generated code to use 'this.' prefix and foreach loops
- Remove TestEnum from audio enums and IDs
- Update SampleScene.unity to use new AudioSystem namespace and rain sound parameter
- Optimize binary serialization in generated audio classes
This commit is contained in:
2026-04-02 14:31:46 +08:00
parent d824d65549
commit 7fc3282e80
18 changed files with 208 additions and 32 deletions
@@ -31,7 +31,7 @@ namespace OCES.Audio
AudioMixerGroup m_voiceGroup;
AudioSourcePool m_pool;
AudioContainerSelector m_containerSelector;
PitchStepManager m_pitchStepManager;
PitchStepResolver m_pitchStepResolver;
#if UNITY_EDITOR
void Update()
@@ -70,7 +70,7 @@ namespace OCES.Audio
this.m_pool = new AudioSourcePool(transform);
this.m_containerSelector = new AudioContainerSelector();
this.m_pitchStepManager = new PitchStepManager();
this.m_pitchStepResolver = new PitchStepResolver();
AudioMixerGroup[] sfx = Find("Master/SFX");
if (sfx.Length > 0) this.m_sfxGroup = sfx[0];
@@ -166,7 +166,7 @@ namespace OCES.Audio
}
// 执行播放
float pitch = this.m_pitchStepManager.ResolvePitch(audioObject, now); //算一下用不用变调
float pitch = this.m_pitchStepResolver.ResolvePitch(audioObject, now); //算一下用不用变调
PlayNewSound(audioObject, pitch);
this.m_lastPlayTime[audioObject.Id] = now;
}