Audio Settings

This commit is contained in:
Zoe J
2022-02-21 00:21:08 -06:00
parent 4a942a73fb
commit 4ee32def84
8 changed files with 3659 additions and 51 deletions
+26
View File
@@ -0,0 +1,26 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Audio;
public class AudioManager : MonoBehaviour
{
public AudioMixer theMixer;
void Start()
{
if (PlayerPrefs.HasKey("MasterVol"))
{
theMixer.SetFloat("MasterVol", PlayerPrefs.GetFloat("MasterVol"));
}
if (PlayerPrefs.HasKey("MusicVol"))
{
theMixer.SetFloat("MusicVol", PlayerPrefs.GetFloat("MusicVol"));
}
if (PlayerPrefs.HasKey("SFXVol"))
{
theMixer.SetFloat("SFXVol", PlayerPrefs.GetFloat("SFXVol"));
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ff8c6d62e5fc0f6478840a18add47f3a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+144
View File
@@ -0,0 +1,144 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!243 &-7289459987239430450
AudioMixerGroupController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: SFX
m_AudioMixer: {fileID: 24100000}
m_GroupID: d161be8aa53901b47b5b21111de006f5
m_Children: []
m_Volume: da0ff497ee2d45c4e8eb35ef605e5af0
m_Pitch: 860ad559d22c6104d96bd91b3c7e2b98
m_Send: 00000000000000000000000000000000
m_Effects:
- {fileID: 4911950373511324649}
m_UserColorIndex: 0
m_Mute: 0
m_Solo: 0
m_BypassEffects: 0
--- !u!243 &-4387083310922404584
AudioMixerGroupController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Music
m_AudioMixer: {fileID: 24100000}
m_GroupID: b52182c193517d44fbee4ebb5752cdd3
m_Children: []
m_Volume: 0d53fe17738958f459398ba3b89e2075
m_Pitch: 7de626099c3197146a33ee31cc624fe1
m_Send: 00000000000000000000000000000000
m_Effects:
- {fileID: -901686731692607832}
m_UserColorIndex: 0
m_Mute: 0
m_Solo: 0
m_BypassEffects: 0
--- !u!244 &-901686731692607832
AudioMixerEffectController:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_EffectID: a6a8b78c939aab340a4fe364d04a8adf
m_EffectName: Attenuation
m_MixLevel: a188e28f9a3bad248817184de4f8c706
m_Parameters: []
m_SendTarget: {fileID: 0}
m_EnableWetMix: 0
m_Bypass: 0
--- !u!241 &24100000
AudioMixerController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Main Mixer
m_OutputGroup: {fileID: 0}
m_MasterGroup: {fileID: 24300002}
m_Snapshots:
- {fileID: 24500006}
m_StartSnapshot: {fileID: 24500006}
m_SuspendThreshold: -80
m_EnableSuspend: 1
m_UpdateMode: 0
m_ExposedParameters:
- guid: 49ab6a0d2da5edc4e906645734208d18
name: MasterVol
- guid: 0d53fe17738958f459398ba3b89e2075
name: MusicVol
- guid: da0ff497ee2d45c4e8eb35ef605e5af0
name: SFXVol
m_AudioMixerGroupViews:
- guids:
- 6ff40938251f24d4794964c9287ddaa9
- b52182c193517d44fbee4ebb5752cdd3
- d161be8aa53901b47b5b21111de006f5
name: View
m_CurrentViewIndex: 0
m_TargetSnapshot: {fileID: 24500006}
--- !u!243 &24300002
AudioMixerGroupController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Master
m_AudioMixer: {fileID: 24100000}
m_GroupID: 6ff40938251f24d4794964c9287ddaa9
m_Children:
- {fileID: -4387083310922404584}
- {fileID: -7289459987239430450}
m_Volume: 49ab6a0d2da5edc4e906645734208d18
m_Pitch: 90c307b891f0b97499b7ea7a3473c370
m_Send: 00000000000000000000000000000000
m_Effects:
- {fileID: 24400004}
m_UserColorIndex: 0
m_Mute: 0
m_Solo: 0
m_BypassEffects: 0
--- !u!244 &24400004
AudioMixerEffectController:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_EffectID: f9f07f365903b224a95ce6022bd36bcf
m_EffectName: Attenuation
m_MixLevel: cbe802496c7bd174d8251e396eba177f
m_Parameters: []
m_SendTarget: {fileID: 0}
m_EnableWetMix: 0
m_Bypass: 0
--- !u!245 &24500006
AudioMixerSnapshotController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Snapshot
m_AudioMixer: {fileID: 24100000}
m_SnapshotID: 969a8d4c953f4d847bbf66360a7242a1
m_FloatValues: {}
m_TransitionOverrides: {}
--- !u!244 &4911950373511324649
AudioMixerEffectController:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_EffectID: 7934aa494e787544a900108ec81ba6a1
m_EffectName: Attenuation
m_MixLevel: 29ea72e6d762ef144bc81f09e3fbc414
m_Parameters: []
m_SendTarget: {fileID: 0}
m_EnableWetMix: 0
m_Bypass: 0
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c97f543260ac6cb409ed0760fe78c9a9
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 24100000
userData:
assetBundleName:
assetBundleVariant:
File diff suppressed because one or more lines are too long
@@ -42,7 +42,7 @@ public class mainMenu : MonoBehaviour
}
public void CloseCredits()
{
{
creditsScreen.SetActive(false);
}
+36 -1
View File
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using UnityEngine.Audio;
public class OptionsScreen : MonoBehaviour
{
@@ -11,6 +12,9 @@ public class OptionsScreen : MonoBehaviour
public List<ResItem> resolutions = new List<ResItem>();
private int selectedResolution;
public TMP_Text resolutionLabel;
public AudioMixer theMixer;
public TMP_Text masterLabel, musicLabel, SFXLabel;
public Slider masterSlider, musicSlider, SFXSlider;
// Start is called before the first frame update
void Start()
@@ -44,6 +48,18 @@ public class OptionsScreen : MonoBehaviour
selectedResolution = resolutions.Count - 1;
UpdateResLabel();
}
float vol = 0f;
theMixer.GetFloat("MasterVol", out vol);
masterSlider.value = vol;
theMixer.GetFloat("MusicVol", out vol);
musicSlider.value = vol;
theMixer.GetFloat("SFXVol", out vol);
SFXSlider.value = vol;
masterLabel.text = Mathf.RoundToInt(masterSlider.value *5/3+100).ToString();
musicLabel.text = Mathf.RoundToInt(musicSlider.value *5/3+100).ToString();
SFXLabel.text = Mathf.RoundToInt(SFXSlider.value *5/3+100).ToString();
}
// Update is called once per frame
@@ -91,7 +107,26 @@ public class OptionsScreen : MonoBehaviour
Screen.SetResolution(resolutions[selectedResolution].horizontal, resolutions[selectedResolution].vertical, fullscreenTog.isOn);
}
public void SetMasterVol()
{
masterLabel.text = Mathf.RoundToInt(masterSlider.value *5/3+100).ToString();
theMixer.SetFloat("MasterVol", masterSlider.value);
PlayerPrefs.SetFloat("MasterVol", masterSlider.value);
}
public void SetMusicVol()
{
musicLabel.text = Mathf.RoundToInt(musicSlider.value *5/3+100).ToString();
theMixer.SetFloat("MusicVol", musicSlider.value);
PlayerPrefs.SetFloat("MusicVol", musicSlider.value);
}
public void SetSFXVol()
{
SFXLabel.text = Mathf.RoundToInt((SFXSlider.value *5/3+100)).ToString();
theMixer.SetFloat("SFXVol", SFXSlider.value);
PlayerPrefs.SetFloat("SFXVol", SFXSlider.value);
}
}
[System.Serializable]
public class ResItem
+2435 -4
View File
File diff suppressed because it is too large Load Diff