This commit is contained in:
OliverS 2024-04-21 11:43:52 +02:00
commit 15a8e135df
9 changed files with 175 additions and 9 deletions

69
Assets/Master.mixer Normal file
View File

@ -0,0 +1,69 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!241 &24100000
AudioMixerController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Master
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: []
m_AudioMixerGroupViews:
- guids:
- 3040ff61b25861248a20f3b92dce8b2f
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: 3040ff61b25861248a20f3b92dce8b2f
m_Children: []
m_Volume: a91398c1df0d04aef95a90980d612ecb
m_Pitch: 735e2b9e4c7099505b97e71cc13a68d6
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: 6c86363194ae90edca59e8ce2e55844b
m_EffectName: Attenuation
m_MixLevel: 5fe356cb290dfad2eb70015bbf3b1034
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: 8ffb606daeece758c860460b0d5e4bef
m_FloatValues:
a91398c1df0d04aef95a90980d612ecb: 0
m_TransitionOverrides: {}

8
Assets/Master.mixer.meta Normal file
View File

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

View File

@ -56,6 +56,7 @@ MonoBehaviour:
health: 0
startHealth: 100
CurrentNumEnemies: 0
Volume: 10
--- !u!114 &6434302952035194364
MonoBehaviour:
m_ObjectHideFlags: 0
@ -69,6 +70,8 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
audioLibrary: {fileID: 11400000, guid: 33d9499f0cd319b2eab27cf0f8e39a40, type: 2}
mixer: {fileID: 24300002, guid: 8cf15f9ce587aa00ea29d786b6dec264, type: 2}
sfxMixer: {fileID: 24300002, guid: bcb05fb4c7c7e785090bc8c2705dd01d, type: 2}
--- !u!114 &4575217513678934597
MonoBehaviour:
m_ObjectHideFlags: 0

69
Assets/SFX.mixer Normal file
View File

@ -0,0 +1,69 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!241 &24100000
AudioMixerController:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: SFX
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: []
m_AudioMixerGroupViews:
- guids:
- e77c1fa5721af59c095d9aadbf882f15
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: e77c1fa5721af59c095d9aadbf882f15
m_Children: []
m_Volume: c8f7ce58f80ae81bbb6ef1523770f60e
m_Pitch: de41996096647d2c6bc41281e948de08
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: 216dd1e46b531863cad81d42c9434f8c
m_EffectName: Attenuation
m_MixLevel: 6d6c9f86af26ae7568b3cfff1b0a5c69
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: 9cb0ca034924554339b6f6a27c684119
m_FloatValues:
c8f7ce58f80ae81bbb6ef1523770f60e: 20
m_TransitionOverrides: {}

8
Assets/SFX.mixer.meta Normal file
View File

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

View File

@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.18028352, g: 0.22571376, b: 0.30692244, a: 1}
m_IndirectSpecularColor: {r: 0.18029143, g: 0.22572419, b: 0.30693057, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:

View File

@ -3,12 +3,14 @@ using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Audio;
public class AudioManager : MonoBehaviour
{
public static AudioManager Instance;
public AudioLibraryObject audioLibrary;
public AudioMixerGroup mixer;
public AudioMixerGroup sfxMixer;
private void Awake()
{
@ -31,21 +33,21 @@ public class AudioManager : MonoBehaviour
{
Debug.LogWarning(clip.name);
}
return Instance.audioLibrary.Clips.First(x => x.name == nameOfClip);
return Instance.audioLibrary.Clips.First(x => x.name.ToLower().Replace(" ", "")== nameOfClip.ToLower().Replace(" ", ""));
}
public static AudioSource PlaySound(AudioClip clip, Vector3 sourcePos, bool manuallyHandle = false, bool is3D = true, bool loop = false, bool fadeIn = false)
public static AudioSource PlaySound(AudioClip clip, Vector3 sourcePos, bool manuallyHandle = false, bool is3D = true, bool loop = false, bool fadeIn = false, bool music = false)
{
return PlaySoundInternal(clip, sourcePos, manuallyHandle, is3D, loop, fadeIn);
return PlaySoundInternal(clip, sourcePos, manuallyHandle, is3D, loop, fadeIn, music);
}
public static AudioSource PlaySound(string nameOfClip, Vector3 sourcePos, bool manuallyHandle = false, bool is3D = true, bool loop = false, bool fadeIn = false)
public static AudioSource PlaySound(string nameOfClip, Vector3 sourcePos, bool manuallyHandle = false, bool is3D = true, bool loop = false, bool fadeIn = false, bool music = false)
{
AudioClip clip = FindAudioClip(nameOfClip);
return PlaySoundInternal(clip, sourcePos, manuallyHandle, is3D, loop, fadeIn);
return PlaySoundInternal(clip, sourcePos, manuallyHandle, is3D, loop, fadeIn, music);
}
private static AudioSource PlaySoundInternal(AudioClip clip, Vector3 sourcePos, bool manuallyHandle, bool is3D, bool loop, bool fadeIn)
private static AudioSource PlaySoundInternal(AudioClip clip, Vector3 sourcePos, bool manuallyHandle, bool is3D, bool loop, bool fadeIn, bool music)
{
if (Instance == null)
{
@ -59,6 +61,11 @@ public class AudioManager : MonoBehaviour
audioSource.clip = clip;
sourceObject.transform.position = sourcePos;
sourceObject.transform.parent = Instance.transform;
audioSource.volume = GameManager.Instance.Volume;
if (music)
audioSource.outputAudioMixerGroup = Instance.mixer;
else
audioSource.outputAudioMixerGroup = Instance.sfxMixer;
if (is3D)
{

View File

@ -14,6 +14,8 @@ public class GameManager : MonoBehaviour
public int CurrentNumEnemies = 0;
public float Volume = 10f;
/// <summary>
/// First param: isBuildMode
/// </summary>

View File

@ -32,7 +32,7 @@ public class MusicManager : MonoBehaviour
if (intensity > prevIntinsity)
{
sources[intensity] = AudioManager.PlaySound(intensities[intensity], Vector3.zero, false, false, true, true);
sources[intensity] = AudioManager.PlaySound(intensities[intensity], Vector3.zero, false, false, true, true, true);
}
else if (intensity < prevIntinsity)
{