game: interim audio mixer

This commit is contained in:
Sc0rch-thinks 2024-08-11 16:27:33 +08:00
parent c800b72ef1
commit fc5ff13fc6
5 changed files with 366 additions and 152 deletions

View file

@ -0,0 +1,207 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!244 &-8022978400122834865
AudioMixerEffectController:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_EffectID: c932bb5f6731ea54dac569b4878a3a86
m_EffectName: Attenuation
m_MixLevel: bc0f3ed364c36c2468eab072598c2831
m_Parameters: []
m_SendTarget: {fileID: 0}
m_EnableWetMix: 0
m_Bypass: 0
--- !u!244 &-5868532137544549062
AudioMixerEffectController:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_EffectID: 25d3c8635da15e7499906b0f132a3e04
m_EffectName: Send
m_MixLevel: 97f1e898bda136f409c04b5750800d41
m_Parameters: []
m_SendTarget: {fileID: 0}
m_EnableWetMix: 0
m_Bypass: 0
--- !u!244 &-4649822107670296378
AudioMixerEffectController:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_EffectID: f31e3e48fa9bc384786ad3fe2a54fd65
m_EffectName: Attenuation
m_MixLevel: 208305a235f8cc94ca498e9adff7d203
m_Parameters: []
m_SendTarget: {fileID: 0}
m_EnableWetMix: 0
m_Bypass: 0
--- !u!244 &-4270897017629866287
AudioMixerEffectController:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_EffectID: 03cebfc5b00432c4ea6a5f3409be35aa
m_EffectName: Highpass Simple
m_MixLevel: b90a96e294a6ed547a2134022c399fa6
m_Parameters:
- m_ParameterName: Cutoff freq
m_GUID: 40d9f93697bf88a4b9155bcfcf9ecd20
m_SendTarget: {fileID: 0}
m_EnableWetMix: 0
m_Bypass: 0
--- !u!244 &-2460124988762949164
AudioMixerEffectController:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_EffectID: 783cabc0e2b3ec845acd2ad3789c6bc0
m_EffectName: Receive
m_MixLevel: aeb8d86a053737b4abd492650e9ee269
m_Parameters: []
m_SendTarget: {fileID: 0}
m_EnableWetMix: 0
m_Bypass: 0
--- !u!244 &-1582468085188204904
AudioMixerEffectController:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
m_EffectID: 2718ae118da2d0a48a74509bc4d9b287
m_EffectName: Send
m_MixLevel: 35cbc92036070e849afb3d56c51d755b
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: audioMixer
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: 293f297885cd2e84b9c272bd815aa6a9
name: MasterVolume
- guid: 9317fd71831c1f2448ec82c581e5e58a
name: MusicVolume
- guid: b132498a0b95b194db66869338d96dfc
name: SFXVolume
m_AudioMixerGroupViews:
- guids:
- b9ed1f259d6dc1d4cb37a79c75ffb4d4
- 107d22cdef956f74b87a9543ca7bc55b
- 989ce34d6d0f0204aa3bf6d1401b128b
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: b9ed1f259d6dc1d4cb37a79c75ffb4d4
m_Children:
- {fileID: 164311610216181747}
- {fileID: 5011515454433698748}
m_Volume: 293f297885cd2e84b9c272bd815aa6a9
m_Pitch: 0c947740d49673f4c93f3827318b2008
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: 0d6cf36c287d5844389026e6d4f293e0
m_EffectName: Attenuation
m_MixLevel: 0495ad7645f15c643bfa1b37f5569a2e
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: 58fe891cd09f4654ab0b24af234b8b9f
m_FloatValues:
9317fd71831c1f2448ec82c581e5e58a: -0.037667945
e7f294e6e737242498112d3976b5c680: 0.49
293f297885cd2e84b9c272bd815aa6a9: -0.88405085
b132498a0b95b194db66869338d96dfc: -0.39762527
9f3337eea0ac80b41a6399fe97ea2af7: 439
m_TransitionOverrides: {}
--- !u!243 &164311610216181747
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: 107d22cdef956f74b87a9543ca7bc55b
m_Children: []
m_Volume: 9317fd71831c1f2448ec82c581e5e58a
m_Pitch: e7f294e6e737242498112d3976b5c680
m_Send: 00000000000000000000000000000000
m_Effects:
- {fileID: -4649822107670296378}
m_UserColorIndex: 0
m_Mute: 0
m_Solo: 0
m_BypassEffects: 0
--- !u!243 &5011515454433698748
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: 989ce34d6d0f0204aa3bf6d1401b128b
m_Children: []
m_Volume: b132498a0b95b194db66869338d96dfc
m_Pitch: ade5573c2a9c2334e97569b43e4d5963
m_Send: 00000000000000000000000000000000
m_Effects:
- {fileID: -8022978400122834865}
m_UserColorIndex: 0
m_Mute: 0
m_Solo: 0
m_BypassEffects: 0

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7cbb70bac0ada294e87675a4a804cde7
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 24100000
userData:
assetBundleName:
assetBundleVariant:

View file

@ -8474,6 +8474,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
associatedState: 2
mixer: {fileID: 24100000, guid: 7cbb70bac0ada294e87675a4a804cde7, type: 2}
--- !u!43 &852189891
Mesh:
m_ObjectHideFlags: 0
@ -12924,6 +12925,135 @@ MonoBehaviour:
m_SelectedFaces:
m_SelectedEdges: []
m_SelectedVertices:
--- !u!1 &1332885280
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1332885282}
- component: {fileID: 1332885281}
m_Layer: 0
m_Name: music
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!82 &1332885281
AudioSource:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1332885280}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 164311610216181747, guid: 7cbb70bac0ada294e87675a4a804cde7,
type: 2}
m_audioClip: {fileID: 8300000, guid: 5e07e339ddf1eea44b3c4db9a02dd75c, type: 3}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 1
Mute: 0
Spatialize: 0
SpatializePostEffects: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
- serializedVersion: 3
time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- serializedVersion: 3
time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
weightedMode: 0
inWeight: 0.33333334
outWeight: 0.33333334
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
--- !u!4 &1332885282
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1332885280}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 483.05478, y: 0.9047287, z: 496.26224}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!43 &1466442468
Mesh:
m_ObjectHideFlags: 0
@ -27116,3 +27246,4 @@ SceneRoots:
- {fileID: 1060921176}
- {fileID: 596429548}
- {fileID: 897146492}
- {fileID: 1332885282}

View file

@ -4,6 +4,10 @@
* description: option menu script for handling credits menu button functions
*/
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.Serialization;
using UnityEngine.UIElements;
/// <summary>
@ -11,6 +15,8 @@
/// </summary>
public class ScreenOptionsMenu : CommonMenu
{
public AudioMixer mixer;
/// <summary>
/// button to return to the main menu
/// </summary>
@ -56,7 +62,7 @@ public override void OnEnable()
// get the music slider from the ui root
SliderAudioMusic = UI.Q<Slider>("MusicSlider");
// TODO: and set the initial value to the current music volume
// SliderAudioMusic.value = Audio.GetMusicVolume() * 100;
// and subscribe appropriate functions
SliderAudioMusic.RegisterCallback<ChangeEvent<float>>(OptionSetMusicVolume);
@ -68,6 +74,16 @@ public override void OnEnable()
SliderAudioSfx.RegisterCallback<ChangeEvent<float>>(OptionSetSfxVolume);
}
public void Start()
{
}
private static float ConvertVolume(float linearVolume)
{
return Mathf.Log10(math.max(0.0000001f, linearVolume / 100)) * 20;
}
/// <summary>
/// handle music volume slider change,
/// sets the music channel volume in the audio manager appropriately
@ -75,8 +91,7 @@ public override void OnEnable()
/// <param name="evt">change event</param>
private void OptionSetMasterVolume(ChangeEvent<float> evt)
{
// TODO: slider is from 0 to 100, convert to 0 to 1, and set
// Audio.SetMusicVolume(evt.newValue / 100);
mixer.SetFloat("MasterVolume", ConvertVolume(evt.newValue));
}
/// <summary>
@ -86,8 +101,7 @@ private void OptionSetMasterVolume(ChangeEvent<float> evt)
/// <param name="evt">change event</param>
private void OptionSetMusicVolume(ChangeEvent<float> evt)
{
// TODO: slider is from 0 to 100, convert to 0 to 1, and set
// Audio.SetMusicVolume(evt.newValue / 100);
mixer.SetFloat("MusicVolume", ConvertVolume(evt.newValue));
}
/// <summary>
@ -97,7 +111,6 @@ private void OptionSetMusicVolume(ChangeEvent<float> evt)
/// <param name="evt">change event</param>
private void OptionSetSfxVolume(ChangeEvent<float> evt)
{
// TODO: slider is from 0 to 100, convert to 0 to 1, and set
// Audio.SetSfxVolume(evt.newValue / 100);
mixer.SetFloat("SFXVolume", ConvertVolume(evt.newValue));
}
}

View file

@ -30,151 +30,6 @@
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "lightmapping.autoUnwrapLightmapUV",
"value": "{\"m_Value\":true}"
},
{
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "UnityEngine.ProBuilder.ProBuilderEditor-isUtilityWindow",
"value": "{\"m_Value\":false}"
},
{
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "editor.backFaceSelectEnabled",
"value": "{\"m_Value\":false}"
},
{
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "editor.toolbarIconGUI",
"value": "{\"m_Value\":false}"
},
{
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "experimental.enabled",
"value": "{\"m_Value\":false}"
},
{
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "editor.showSceneInfo",
"value": "{\"m_Value\":false}"
},
{
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "ShapeComponent.ResetSettings",
"value": "{\"m_Value\":false}"
},
{
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "ShapeComponent.SettingsEnabled",
"value": "{\"m_Value\":true}"
},
{
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "mesh.newShapesSnapToGrid",
"value": "{\"m_Value\":true}"
},
{
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "mesh.meshColliderIsConvex",
"value": "{\"m_Value\":false}"
},
{
"type": "System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "editor.autoRecalculateCollisions",
"value": "{\"m_Value\":false}"
},
{
"type": "UnityEngine.ProBuilder.SelectMode, Unity.ProBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "editor.selectMode",
"value": "{\"m_Value\":1}"
},
{
"type": "UnityEngine.ProBuilder.SelectionModifierBehavior, Unity.ProBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "editor.rectSelectModifier",
"value": "{\"m_Value\":2}"
},
{
"type": "UnityEngine.ProBuilder.RectSelectMode, Unity.ProBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "editor.dragSelectRectMode",
"value": "{\"m_Value\":0}"
},
{
"type": "System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "ShapeBuilder.ActiveShapeIndex",
"value": "{\"m_Value\":9}"
},
{
"type": "System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"key": "ShapeBuilder.LastPivotLocation",
"value": "{\"m_Value\":1}"
},
{
"type": "UnityEngine.ProBuilder.PivotLocation, Unity.ProBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "mesh.newShapePivotLocation",
"value": "{\"m_Value\":1}"
},
{
"type": "UnityEngine.Vector3, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "ShapeBuilder.LastPivotPosition",
"value": "{\"m_Value\":{\"x\":0.0,\"y\":0.0,\"z\":0.0}}"
},
{
"type": "UnityEngine.Vector3, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "ShapeBuilder.LastSize",
"value": "{\"m_Value\":{\"x\":2.637908935546875,\"y\":0.6330699920654297,\"z\":2.631824493408203}}"
},
{
"type": "UnityEngine.Quaternion, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "ShapeBuilder.LastRotation",
"value": "{\"m_Value\":{\"x\":0.0,\"y\":0.0,\"z\":0.0,\"w\":1.0}}"
},
{
"type": "UnityEngine.Material, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "mesh.userMaterial",
"value": "{\"m_Value\":{\"instanceID\":0}}"
},
{
"type": "UnityEngine.Rendering.ShadowCastingMode, UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "mesh.shadowCastingMode",
"value": "{\"m_Value\":1}"
},
{
"type": "UnityEditor.StaticEditorFlags, UnityEditor.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "mesh.defaultStaticEditorFlags",
"value": "{\"m_Value\":0}"
},
{
"type": "UnityEngine.ProBuilder.ColliderType, Unity.ProBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "mesh.newShapeColliderType",
"value": "{\"m_Value\":2}"
},
{
"type": "UnityEngine.ProBuilder.UnwrapParameters, Unity.ProBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "lightmapping.defaultLightmapUnwrapParameters",
"value": "{\"m_Value\":{\"m_HardAngle\":88.0,\"m_PackMargin\":20.0,\"m_AngleError\":8.0,\"m_AreaError\":15.0}}"
},
{
"type": "UnityEngine.ProBuilder.Shapes.Shape, Unity.ProBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "ShapeBuilder.Plane",
"value": "{}"
},
{
"type": "UnityEngine.ProBuilder.Shapes.Shape, Unity.ProBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "ShapeBuilder.Stairs",
"value": "{}"
},
{
"type": "UnityEngine.ProBuilder.Shapes.Shape, Unity.ProBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "ShapeBuilder.Cube",
"value": "{}"
},
{
"type": "UnityEngine.ProBuilder.Shapes.Shape, Unity.ProBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "ShapeBuilder.Cone",
"value": "{}"
},
{
"type": "UnityEngine.ProBuilder.Shapes.Shape, Unity.ProBuilder, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null",
"key": "ShapeBuilder.Torus",
"value": "{}"
}
]
}