From 7b9e1a339378059ae28cda566d2636db9ab0ba0d Mon Sep 17 00:00:00 2001 From: Oliver Wong Date: Mon, 13 Apr 2026 16:56:34 +0800 Subject: [PATCH 1/2] feat: implement volume step feature - Add volume step functionality with VolumeStepResolver class - Add VolumeStepThreshold, Volume, and VolumeStep properties to AudioObject - Integrate volume step resolution in SfxSystem for dynamic audio volume control --- Assets/Plugins/iOS.meta | 8 ++++ .../Plugins/iOS/LofeltHaptics.framework.meta | 33 +++++++++++++++ Assets/Resources/AudioData/AudioObject.bytes | Bin 7567 -> 9237 bytes .../Resources/AudioData/MusicContainer.bytes | Bin 107 -> 110 bytes .../Resources/AudioData/MusicTransition.bytes | Bin 29 -> 29 bytes .../au_sfx_notice_level_countDown_edge.wav | 3 ++ ...u_sfx_notice_level_countDown_edge.wav.meta | 23 ++++++++++ .../au_sfx_notice_level_countDown_time.wav | 3 ++ ...u_sfx_notice_level_countDown_time.wav.meta | 23 ++++++++++ Assets/Scenes/SampleScene.unity | 18 ++++++-- .../OCES/Audio/Generated/AudioObject.cs | 23 ++++++++++ .../Audio/Generated/AudioObjectDefinitions.cs | 7 +++ .../OCES/Audio/HandWritten/SfxSystem.cs | 25 +++++++---- .../Audio/HandWritten/VolumeStepResolver.cs | 40 ++++++++++++++++++ .../HandWritten/VolumeStepResolver.cs.meta | 3 ++ 15 files changed, 198 insertions(+), 11 deletions(-) create mode 100644 Assets/Plugins/iOS.meta create mode 100644 Assets/Plugins/iOS/LofeltHaptics.framework.meta create mode 100644 Assets/Resources/Audios/au_sfx_notice_level_countDown_edge.wav create mode 100644 Assets/Resources/Audios/au_sfx_notice_level_countDown_edge.wav.meta create mode 100644 Assets/Resources/Audios/au_sfx_notice_level_countDown_time.wav create mode 100644 Assets/Resources/Audios/au_sfx_notice_level_countDown_time.wav.meta create mode 100644 Assets/Scripts/OCES/Audio/HandWritten/VolumeStepResolver.cs create mode 100644 Assets/Scripts/OCES/Audio/HandWritten/VolumeStepResolver.cs.meta diff --git a/Assets/Plugins/iOS.meta b/Assets/Plugins/iOS.meta new file mode 100644 index 0000000..f20b5c7 --- /dev/null +++ b/Assets/Plugins/iOS.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3cc8ce9203c4a4d03b07e0ae9a3cf219 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Plugins/iOS/LofeltHaptics.framework.meta b/Assets/Plugins/iOS/LofeltHaptics.framework.meta new file mode 100644 index 0000000..91e3981 --- /dev/null +++ b/Assets/Plugins/iOS/LofeltHaptics.framework.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 3f3b3e40c5ec34183af765f15c1ce362 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + iPhone: iOS + second: + enabled: 1 + settings: + AddToEmbeddedBinaries: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/AudioData/AudioObject.bytes b/Assets/Resources/AudioData/AudioObject.bytes index e7a67fb201226a0f15b053eb115b978127c4750b..f0560b93d0013f9958a55688d2c8bb4ab556d61c 100644 GIT binary patch delta 1037 zcma))OH30{6oxyUK4?3o5Bj7fni>;>ZZw5b!B-_Zf}l;Lh*G9wJ0&I1CT&4o5L~-4 z!cT)06KNPoXfQLVTuJ$!5HVZWe9Vk^&EJ?+7GT+Y3_xU^1fQ>oP##XU9eI8G1uR0 zr{U|hQ(oDA4Elkca^Bg=7wDk9CpkAbKXr^^{*VKA#)=N|tvk-3{?UO;WF9Bo!blQH1&RG~t$}x?BkZ!^McmfjZz*Z`1mi1a)ViKcwEONp zUbAF0wYgjD-z}c6S4zC-N%5j>JU3h^YI-(e93hy4!2#Zo#&fc!)|)qsq(-~#Yqt-l zc{`ylDvk0jrCMtmc4b~$(&m+7ZL!)MuHCFET4~nEOr$PaOs4OxR!cN&$N$gTtSq#x zj(=9xlIW60-1KLxx+icOU)(AvcNV}WounO}E6{n*CGZ*PRWI2lywrZ`Eu-!6T>~q= zJh;Vqz&{PW!nxz0f=+f7!Syck|KThKCQ*MCpu9jZ3#|ny_f2pHdVeSfE`_MS9l8p= zFHHUA@EG*lFs;=anT6IPq<=){963rkkD|2K&nVSLy6L=4PD_mTD8#NK=XI<^=f&xr S%*Sc3mvNf&_bjtQPvkFT_dA#X delta 410 zcmWN?O-xb&0Kjn{-|!GZAOZOZz3DuN?*$B{gkoTPru~~7`YT-dS6B^H_!_9<4_0^)?C>YJLHVY}ks&tT;I&~mzRqf>%^=iaKHT9$ zxP~LL!Lx|UNkl`MX!34itru0%qICw*CNr^RUd3AIvB$LIEl%S#Qi(MV5>+k}HR`uC d28QWmgI@9>*U3jbnauNTa-GmrgPp0D{{iruk|F>A diff --git a/Assets/Resources/AudioData/MusicContainer.bytes b/Assets/Resources/AudioData/MusicContainer.bytes index abcd11db77a93e98ee5141b7a0835836bb6604ae..1e7525a95bab4f669bafb7a5ddaad75c293b0fb9 100644 GIT binary patch delta 20 bcmd1Kn;^mXV4|cfyPz|(iM|QTL@Pr8J#7Ua delta 17 Xcmd1Ho*=>aZla_t3j+{Lv^4|(ExZIf diff --git a/Assets/Resources/AudioData/MusicTransition.bytes b/Assets/Resources/AudioData/MusicTransition.bytes index a18a9fc7a39ed25a0347db57342feaec168c0ea2..68f1c4ca1fea80dca9fbff1030af67ca62fabeed 100644 GIT binary patch literal 29 RcmZQ%U|_I!;s=sg000f@0FnRz literal 29 WcmZQ%U|_I!;s=rq_CNxO1~LI7&H@ks diff --git a/Assets/Resources/Audios/au_sfx_notice_level_countDown_edge.wav b/Assets/Resources/Audios/au_sfx_notice_level_countDown_edge.wav new file mode 100644 index 0000000..d5ba137 --- /dev/null +++ b/Assets/Resources/Audios/au_sfx_notice_level_countDown_edge.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1e832d9b133d74f1d9723c8605881ba305c37d2e0ed3767efa8014949bfadf22 +size 251992 diff --git a/Assets/Resources/Audios/au_sfx_notice_level_countDown_edge.wav.meta b/Assets/Resources/Audios/au_sfx_notice_level_countDown_edge.wav.meta new file mode 100644 index 0000000..c43db99 --- /dev/null +++ b/Assets/Resources/Audios/au_sfx_notice_level_countDown_edge.wav.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: e640dc3c900064126804112a521170ea +AudioImporter: + externalObjects: {} + serializedVersion: 7 + defaultSettings: + serializedVersion: 2 + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + preloadAudioData: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/Audios/au_sfx_notice_level_countDown_time.wav b/Assets/Resources/Audios/au_sfx_notice_level_countDown_time.wav new file mode 100644 index 0000000..6c2fc02 --- /dev/null +++ b/Assets/Resources/Audios/au_sfx_notice_level_countDown_time.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:277376c43a54a39ff777d5843c5aff20a2457fdc579668e8cb83a050699d8166 +size 109256 diff --git a/Assets/Resources/Audios/au_sfx_notice_level_countDown_time.wav.meta b/Assets/Resources/Audios/au_sfx_notice_level_countDown_time.wav.meta new file mode 100644 index 0000000..575ddb8 --- /dev/null +++ b/Assets/Resources/Audios/au_sfx_notice_level_countDown_time.wav.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: be8f215dba3904ddf9f72fc064c97e71 +AudioImporter: + externalObjects: {} + serializedVersion: 7 + defaultSettings: + serializedVersion: 2 + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + preloadAudioData: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + loadInBackground: 0 + ambisonic: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index e3f8118..eb910d9 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -1012,7 +1012,7 @@ GameObject: - component: {fileID: 1394234350} - component: {fileID: 1394234349} m_Layer: 5 - m_Name: Button (Legacy) + m_Name: PlaySound m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -1085,15 +1085,27 @@ MonoBehaviour: - m_Target: {fileID: 2093584670} m_TargetAssemblyTypeName: OCES.Audio.AudioSystem, Assembly-CSharp m_MethodName: Play - m_Mode: 5 + m_Mode: 3 m_Arguments: m_ObjectArgument: {fileID: 0} m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine - m_IntArgument: 11 + m_IntArgument: 57 m_FloatArgument: 0 m_StringArgument: rain m_BoolArgument: 0 m_CallState: 2 + - m_Target: {fileID: 2093584670} + m_TargetAssemblyTypeName: OCES.Audio.AudioSystem, Assembly-CSharp + m_MethodName: Play + m_Mode: 3 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 58 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 --- !u!114 &1394234350 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/OCES/Audio/Generated/AudioObject.cs b/Assets/Scripts/OCES/Audio/Generated/AudioObject.cs index 3f33ccf..50683c3 100644 --- a/Assets/Scripts/OCES/Audio/Generated/AudioObject.cs +++ b/Assets/Scripts/OCES/Audio/Generated/AudioObject.cs @@ -130,6 +130,23 @@ public partial class AudioObject : IBinarySerializable /// public bool RandomType { get; set; } + /// + /// Volume Step阈值 ms + /// + public uint VolumeStepThreshold { get; set; } + + /// + /// 起始音量 + /// dB + /// + public int Volume { get; set; } + + /// + /// 音量变化幅度 + /// dB + /// + public int VolumeStep { get; set; } + public void DeSerialize(BinaryReader reader) { @@ -166,6 +183,9 @@ public partial class AudioObject : IBinarySerializable BlendCrossFadeType = (BlendCrossFadeType)reader.ReadByte(); LimitRepetition = reader.ReadByte(); RandomType = reader.ReadBoolean(); + VolumeStepThreshold = reader.ReadUInt32(); + Volume = reader.ReadInt32(); + VolumeStep = reader.ReadInt32(); } public void Serialize(BinaryWriter writer) @@ -202,6 +222,9 @@ public partial class AudioObject : IBinarySerializable writer.Write((byte)BlendCrossFadeType); writer.Write(LimitRepetition); writer.Write(RandomType); + writer.Write(VolumeStepThreshold); + writer.Write(Volume); + writer.Write(VolumeStep); } } diff --git a/Assets/Scripts/OCES/Audio/Generated/AudioObjectDefinitions.cs b/Assets/Scripts/OCES/Audio/Generated/AudioObjectDefinitions.cs index 51ddc04..e54a9e6 100644 --- a/Assets/Scripts/OCES/Audio/Generated/AudioObjectDefinitions.cs +++ b/Assets/Scripts/OCES/Audio/Generated/AudioObjectDefinitions.cs @@ -66,6 +66,13 @@ public static class AudioObjectDefinitions { "Chinese Number 08", 49 }, { "Chinese Number 09", 49 }, { "Chinese Number 10", 49 }, + { "Bar", 52 }, + { "Beat", 53 }, + { "Grid", 54 }, + { "NVDice", 55 }, + { "NVHeartbeats", 56 }, + { "au_sfx_notice_level_countDown_edge", 57 }, + { "au_sfx_notice_level_countDown_time", 58 }, { "sfx_amb_desert", 2000 }, { "sfx_amb_forest", 2001 }, { "sfx_anim_common_item_fly", 3000 }, diff --git a/Assets/Scripts/OCES/Audio/HandWritten/SfxSystem.cs b/Assets/Scripts/OCES/Audio/HandWritten/SfxSystem.cs index d307afd..e033cd3 100644 --- a/Assets/Scripts/OCES/Audio/HandWritten/SfxSystem.cs +++ b/Assets/Scripts/OCES/Audio/HandWritten/SfxSystem.cs @@ -2,6 +2,7 @@ using System; using System.Collections; using System.Collections.Generic; using System.Linq; +using OCES.Audio.HandWritten; using UnityEngine; using UnityEngine.Audio; @@ -33,6 +34,7 @@ namespace OCES.Audio AudioSourcePool m_pool; AudioContainerSelector m_containerSelector; PitchStepResolver m_pitchStepResolver; + VolumeStepResolver m_volumeStepResolver; #if UNITY_EDITOR void Update() @@ -74,6 +76,7 @@ namespace OCES.Audio this.m_pool = pool; this.m_containerSelector = new AudioContainerSelector(); this.m_pitchStepResolver = new PitchStepResolver(); + this.m_volumeStepResolver = new VolumeStepResolver(); AudioMixerGroup[] sfx = Find("Master/Regular/SFX"); if (sfx.Length > 0) this.m_sfxGroup = sfx[0]; @@ -173,7 +176,8 @@ namespace OCES.Audio // 执行播放 float pitch = this.m_pitchStepResolver.ResolvePitch(audioObject, now); //算一下用不用变调 - PlayNewSound(audioObject, pitch); + float volume = this.m_volumeStepResolver.ResolveVolume(audioObject, now); + PlayNewSound(audioObject, pitch, volume); this.m_lastPlayTime[audioObject.Id] = now; onPlay?.Invoke(); } @@ -182,12 +186,13 @@ namespace OCES.Audio // 播放逻辑 // ───────────────────────────────────────────── - void PlayNewSound(AudioObject audioObject, float pitch) + void PlayNewSound(AudioObject audioObject, float pitch, float volume) { ActiveSound active = new() { AudioObject = audioObject, Pitch = pitch, + Volume = volume, State = ActiveSoundState.Pending, StartTime = Time.realtimeSinceStartupAsDouble, }; @@ -207,7 +212,7 @@ namespace OCES.Audio /// /// 连续容器播放协程(Random / Sequence 持续模式) /// - IEnumerator PlayContainerContinuous(AudioSource source, AudioObject audioObject, ActiveSound chainActive, int startIndex, float pitch) + IEnumerator PlayContainerContinuous(AudioSource source, AudioObject audioObject, ActiveSound chainActive, int startIndex, float pitch, float volume) { bool isRandom = audioObject.ContainerType == ContainerType.Random; @@ -229,7 +234,7 @@ namespace OCES.Audio limitRepetition); // 配置并播放 - if (!SetupSource(source, audioObject, pitch, index)) + if (!SetupSource(source, audioObject, pitch, volume,index)) { Debug.LogError($"音频文件未找到:{audioObject.Name[index]}"); yield break; @@ -334,7 +339,7 @@ namespace OCES.Audio return this.m_sfxGroup; } - bool SetupSource(AudioSource source, AudioObject audioObject, float pitch, int clipIndex = 0) + bool SetupSource(AudioSource source, AudioObject audioObject, float pitch, float volume, int clipIndex = 0) { AudioClip clip = Resources.Load($"Audios/{audioObject.Name[clipIndex]}"); // TODO 抽象同一资源加载接口 if (!clip) @@ -348,6 +353,7 @@ namespace OCES.Audio source.priority = audioObject.Priority; source.outputAudioMixerGroup = GetMixerGroup(audioObject.MixingType); source.pitch = pitch; + source.volume = volume; return true; } @@ -371,6 +377,7 @@ namespace OCES.Audio { AudioObject audioObject = active.AudioObject; float pitch = active.Pitch; + float volume = active.Volume; // ======================= // Blend(每个clip一个ActiveSound) @@ -385,10 +392,11 @@ namespace OCES.Audio { AudioObject = audioObject, Pitch = pitch, + Volume = volume, State = ActiveSoundState.Playing }; - if (!SetupSource(source, audioObject, pitch, i)) + if (!SetupSource(source, audioObject, pitch, volume, i)) { this.m_pool.ReturnToPool(source.gameObject); continue; @@ -424,7 +432,7 @@ namespace OCES.Audio int start = audioObject.ContainerType == ContainerType.Random ? -1 : 0; active.Coroutine = StartCoroutine( - PlayContainerContinuous(sourceSingle, audioObject, active, start, pitch) + PlayContainerContinuous(sourceSingle, audioObject, active, start, pitch, volume) ); return; @@ -440,7 +448,7 @@ namespace OCES.Audio _ => 0 }; - if (!SetupSource(sourceSingle, audioObject, pitch, index)) + if (!SetupSource(sourceSingle, audioObject, pitch, volume, index)) { m_pool.ReturnToPool(sourceSingle.gameObject); return; @@ -506,6 +514,7 @@ namespace OCES.Audio public int CurrentLoopCount; public Coroutine Coroutine; public float Pitch; + public float Volume; public ActiveSoundState State; } } \ No newline at end of file diff --git a/Assets/Scripts/OCES/Audio/HandWritten/VolumeStepResolver.cs b/Assets/Scripts/OCES/Audio/HandWritten/VolumeStepResolver.cs new file mode 100644 index 0000000..ae5e8ad --- /dev/null +++ b/Assets/Scripts/OCES/Audio/HandWritten/VolumeStepResolver.cs @@ -0,0 +1,40 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace OCES.Audio.HandWritten +{ + public class VolumeStepResolver + { + readonly Dictionary m_volumeStepCounts = new(); + readonly Dictionary m_volumeStepLastTime = new(); + + internal float ResolveVolume(AudioObject audioObject, double time) + { + // 计算一下配置的音量是多少 + float baseVolume = Mathf.Pow(10,audioObject.Volume / 20f); + + // 优化版。看看表现,要是确实Mathf.Pow造成性能卡点了就用这个。 + //float baseVolume = audioObject.Volume == 0 ? 1f : Mathf.Pow(10,audioObject.Volume / 20f); + + if (audioObject.VolumeStepThreshold == 0) //没配置VolumeStep + { + return baseVolume; + } + + // 超时了,或者没播过 + if (!this.m_volumeStepLastTime.TryGetValue(audioObject.Id, out double lastVolumeStepTime) + || time - lastVolumeStepTime > audioObject.VolumeStepThreshold) + { + this.m_volumeStepCounts[audioObject.Id] = 0; + this.m_volumeStepLastTime[audioObject.Id] = time; + return baseVolume; + } + + //命中了 + int volumeStepCount = this.m_volumeStepCounts[audioObject.Id]; + volumeStepCount = this.m_volumeStepCounts[audioObject.Id] = volumeStepCount + 1; + this.m_volumeStepLastTime[audioObject.Id] = time; + return Mathf.Clamp(Mathf.Pow(10, (audioObject.Volume + audioObject.VolumeStep * volumeStepCount) / 20f), 0f, 1f); + } + } +} diff --git a/Assets/Scripts/OCES/Audio/HandWritten/VolumeStepResolver.cs.meta b/Assets/Scripts/OCES/Audio/HandWritten/VolumeStepResolver.cs.meta new file mode 100644 index 0000000..008cac7 --- /dev/null +++ b/Assets/Scripts/OCES/Audio/HandWritten/VolumeStepResolver.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0059d6fc851c474a97bc05f6385f9a48 +timeCreated: 1776067889 \ No newline at end of file From 936c8e388bf5e0d7298051527ab1201801ccbaaf Mon Sep 17 00:00:00 2001 From: Oliver Wong Date: Mon, 13 Apr 2026 17:27:59 +0800 Subject: [PATCH 2/2] =?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; }