From d42a60cd622357e437a78ffa266e0209dbe9891e Mon Sep 17 00:00:00 2001 From: Oliver Wong Date: Mon, 13 Apr 2026 17:27:59 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BD=BF=E7=94=A8ActiveSound?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1=E4=BC=A0=E9=80=92=E9=9F=B3=E9=AB=98=E5=92=8C?= =?UTF-8?q?=E9=9F=B3=E9=87=8F=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OCES/Audio/HandWritten/SfxSystem.cs | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Assets/Scripts/OCES/Audio/HandWritten/SfxSystem.cs b/Assets/Scripts/OCES/Audio/HandWritten/SfxSystem.cs index e033cd3..da454af 100644 --- a/Assets/Scripts/OCES/Audio/HandWritten/SfxSystem.cs +++ b/Assets/Scripts/OCES/Audio/HandWritten/SfxSystem.cs @@ -212,7 +212,7 @@ namespace OCES.Audio /// /// 连续容器播放协程(Random / Sequence 持续模式) /// - IEnumerator PlayContainerContinuous(AudioSource source, AudioObject audioObject, ActiveSound chainActive, int startIndex, float pitch, float volume) + IEnumerator PlayContainerContinuous(AudioSource source, AudioObject audioObject, ActiveSound chainActive, int startIndex) { bool isRandom = audioObject.ContainerType == ContainerType.Random; @@ -234,7 +234,7 @@ namespace OCES.Audio limitRepetition); // 配置并播放 - if (!SetupSource(source, audioObject, pitch, volume,index)) + if (!SetupSource(source, chainActive, index)) { Debug.LogError($"音频文件未找到:{audioObject.Name[index]}"); yield break; @@ -339,8 +339,9 @@ namespace OCES.Audio return this.m_sfxGroup; } - bool SetupSource(AudioSource source, AudioObject audioObject, float pitch, float volume, int clipIndex = 0) + bool SetupSource(AudioSource source, ActiveSound activeSound, int clipIndex = 0) { + AudioObject audioObject = activeSound.AudioObject; AudioClip clip = Resources.Load($"Audios/{audioObject.Name[clipIndex]}"); // TODO 抽象同一资源加载接口 if (!clip) { @@ -352,8 +353,8 @@ namespace OCES.Audio source.loop = audioObject.LoopCount < 0; source.priority = audioObject.Priority; source.outputAudioMixerGroup = GetMixerGroup(audioObject.MixingType); - source.pitch = pitch; - source.volume = volume; + source.pitch = activeSound.Pitch; + source.volume = activeSound.Volume; return true; } @@ -393,10 +394,10 @@ namespace OCES.Audio AudioObject = audioObject, Pitch = pitch, Volume = volume, - State = ActiveSoundState.Playing + State = ActiveSoundState.Playing, }; - if (!SetupSource(source, audioObject, pitch, volume, i)) + if (!SetupSource(source, child, i)) { this.m_pool.ReturnToPool(source.gameObject); continue; @@ -432,7 +433,7 @@ namespace OCES.Audio int start = audioObject.ContainerType == ContainerType.Random ? -1 : 0; active.Coroutine = StartCoroutine( - PlayContainerContinuous(sourceSingle, audioObject, active, start, pitch, volume) + PlayContainerContinuous(sourceSingle, audioObject, active, start) ); return; @@ -448,9 +449,9 @@ namespace OCES.Audio _ => 0 }; - if (!SetupSource(sourceSingle, audioObject, pitch, volume, index)) + if (!SetupSource(sourceSingle, active, index)) { - m_pool.ReturnToPool(sourceSingle.gameObject); + this.m_pool.ReturnToPool(sourceSingle.gameObject); return; }