Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Assets/BossRoom/Prefabs/CharGFX/BossGraphics.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -2056,7 +2056,7 @@ AudioSource:
m_GameObject: {fileID: 6839301660383890230}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
OutputAudioMixerGroup: {fileID: -6199682581367681880, guid: e39f39bfdfb22b541bbc115192fc2809, type: 2}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 0
m_Volume: 1
Expand Down Expand Up @@ -2179,7 +2179,7 @@ AudioSource:
m_GameObject: {fileID: 6839301660383890230}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
OutputAudioMixerGroup: {fileID: -6199682581367681880, guid: e39f39bfdfb22b541bbc115192fc2809, type: 2}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 0
m_Volume: 1
Expand Down Expand Up @@ -2324,7 +2324,7 @@ AudioSource:
m_GameObject: {fileID: 6839301660383890230}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
OutputAudioMixerGroup: {fileID: -4341177700643628062, guid: e39f39bfdfb22b541bbc115192fc2809, type: 2}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 0
m_Volume: 1
Expand Down
6 changes: 3 additions & 3 deletions Assets/BossRoom/Prefabs/CharGFX/ImpGraphics.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -1172,7 +1172,7 @@ AudioSource:
m_GameObject: {fileID: 6839301660383890230}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
OutputAudioMixerGroup: {fileID: -6199682581367681880, guid: e39f39bfdfb22b541bbc115192fc2809, type: 2}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 0
m_Volume: 1
Expand Down Expand Up @@ -1295,7 +1295,7 @@ AudioSource:
m_GameObject: {fileID: 6839301660383890230}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
OutputAudioMixerGroup: {fileID: -6199682581367681880, guid: e39f39bfdfb22b541bbc115192fc2809, type: 2}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 0
m_Volume: 1
Expand Down Expand Up @@ -1440,7 +1440,7 @@ AudioSource:
m_GameObject: {fileID: 6839301660383890230}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
OutputAudioMixerGroup: {fileID: -4341177700643628062, guid: e39f39bfdfb22b541bbc115192fc2809, type: 2}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 0
m_Volume: 1
Expand Down
6 changes: 3 additions & 3 deletions Assets/BossRoom/Prefabs/CharGFX/PlayerGraphics.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -1507,7 +1507,7 @@ AudioSource:
m_GameObject: {fileID: 3736552308919084700}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
OutputAudioMixerGroup: {fileID: -6199682581367681880, guid: e39f39bfdfb22b541bbc115192fc2809, type: 2}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 0
m_Volume: 1
Expand Down Expand Up @@ -1630,7 +1630,7 @@ AudioSource:
m_GameObject: {fileID: 3736552308919084700}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
OutputAudioMixerGroup: {fileID: -6199682581367681880, guid: e39f39bfdfb22b541bbc115192fc2809, type: 2}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 0
m_Volume: 1
Expand Down Expand Up @@ -1775,7 +1775,7 @@ AudioSource:
m_GameObject: {fileID: 3736552308919084700}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
OutputAudioMixerGroup: {fileID: -4341177700643628062, guid: e39f39bfdfb22b541bbc115192fc2809, type: 2}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 0
m_Volume: 1
Expand Down
8 changes: 4 additions & 4 deletions Assets/BossRoom/Prefabs/UI/SettingsPanelCanvas.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -1185,10 +1185,10 @@ MonoBehaviour:
m_FillRect: {fileID: 6005602306300149307}
m_HandleRect: {fileID: 7817392311645474671}
m_Direction: 0
m_MinValue: 0
m_MinValue: 0.0001
m_MaxValue: 1
m_WholeNumbers: 0
m_Value: 0
m_Value: 0.0001
m_OnValueChanged:
m_PersistentCalls:
m_Calls: []
Expand Down Expand Up @@ -1276,10 +1276,10 @@ MonoBehaviour:
m_FillRect: {fileID: 1591034541050051854}
m_HandleRect: {fileID: 1591034541991487326}
m_Direction: 0
m_MinValue: 0
m_MinValue: 0.0001
m_MaxValue: 1
m_WholeNumbers: 0
m_Value: 0
m_Value: 0.0001
m_OnValueChanged:
m_PersistentCalls:
m_Calls: []
Expand Down
4 changes: 2 additions & 2 deletions Assets/BossRoom/Scenes/Startup.unity
Git LFS file not shown
57 changes: 57 additions & 0 deletions Assets/BossRoom/Scripts/Client/Audio/AudioMixerConfigurator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using UnityEngine;
using UnityEngine.Audio;

namespace BossRoom.Client
{
/// <summary>
/// Initializes the game's AudioMixer to use volumes stored in preferences. Provides
/// a public function that can be called when these values change.
/// </summary>
public class AudioMixerConfigurator : MonoBehaviour
{
[SerializeField]
private AudioMixer m_Mixer;

[SerializeField]
private string m_MixerVarMainVolume = "OverallVolume";

[SerializeField]
private string m_MixerVarMusicVolume = "MusicVolume";

public static AudioMixerConfigurator Instance { get; private set; }

/// <summary>
/// The audio sliders use a value between 0.0001 and 1, but the mixer works in decibels -- by default, -80 to 0.
/// To convert, we use log10(slider) multiplied by 20. Why 20? because log10(.0001)*20=-80, which is the
/// bottom range for our mixer, meaning it's disabled.
/// </summary>
private const float k_VolumeLog10Multiplier = 20;

private void Awake()
{
Instance = this;
DontDestroyOnLoad(gameObject);
}

private void Start()
{
// note that trying to configure the AudioMixer during Awake does not work, must be initialized in Start
Configure();
}

public void Configure()
{
m_Mixer.SetFloat(m_MixerVarMainVolume, GetVolumeInDecibels(ClientPrefs.GetMasterVolume()));
m_Mixer.SetFloat(m_MixerVarMusicVolume, GetVolumeInDecibels(ClientPrefs.GetMusicVolume()));
}

private float GetVolumeInDecibels(float volume)
{
if (volume <= 0) // sanity-check in case we have bad prefs data
{
volume = 0.0001f;
}
return Mathf.Log10(volume) * k_VolumeLog10Multiplier;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions Assets/BossRoom/Scripts/Client/Audio/ClientMusicPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,6 @@ private void Awake()
}
DontDestroyOnLoad(gameObject);
Instance = this;
m_source.volume = ClientPrefs.GetMusicVolume();
}

public void SetMusicVolume(float volume)
{
m_source.volume = volume;
}
}
}
4 changes: 2 additions & 2 deletions Assets/BossRoom/Scripts/Client/UI/UISettingsPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ private void OnDisable()

private void OnMasterVolumeSliderChanged(float newValue)
{
AudioListener.volume = newValue;
ClientPrefs.SetMasterVolume(newValue);
AudioMixerConfigurator.Instance.Configure();
}

private void OnMusicVolumeSliderChanged(float newValue)
{
ClientMusicPlayer.Instance.SetMusicVolume(newValue);
ClientPrefs.SetMusicVolume(newValue);
AudioMixerConfigurator.Instance.Configure();
}
}

Expand Down
Loading