From d93e9f6ca7678774dbb9b8e59af4a89c7c2b628c Mon Sep 17 00:00:00 2001 From: Gokhan Kurt Date: Sat, 1 Jun 2024 20:04:40 +0300 Subject: [PATCH] dont store volume and pitch in state --- Runtime/Styling/StyleState.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Runtime/Styling/StyleState.cs b/Runtime/Styling/StyleState.cs index 027ed828..e2240c66 100644 --- a/Runtime/Styling/StyleState.cs +++ b/Runtime/Styling/StyleState.cs @@ -64,8 +64,6 @@ private class AudioState public bool Loaded; public bool Loading; public UnityEngine.AudioClip Clip; - public float Volume; - public float Pitch; public bool ShouldStart; public int CurrentLoop = 0; } @@ -668,12 +666,14 @@ private bool UpdateAudio() var state = audioStates[i] = audioStates[i] ?? new AudioState(); + var curVolume = volume.Get(i, 1); + var curPitch = pitch.Get(i, 1); Action tryPlayClip = () => { if (state.Loaded && state.ShouldStart) { state.ShouldStart = false; - Context.PlayAudio(state.Clip, state.Volume, state.Pitch); + Context.PlayAudio(state.Clip, curVolume, curPitch); } }; @@ -687,8 +687,6 @@ private bool UpdateAudio() clip.Get(i, AudioReference.None).Get(Context, (cl) => { state.Clip = cl; - state.Volume = volume.Get(i, 1); - state.Pitch = pitch.Get(i, 1); state.Loaded = true; state.Loading = false;