This commit is contained in:
BOT Alex 2024-04-21 11:43:58 +02:00
commit 2a0f18491c
11 changed files with 176 additions and 10 deletions

Binary file not shown.

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 872cd5c7e50bb3440b97948159f98c94 guid: ae67a6780911eb448ad8fa90a90c0848
AudioImporter: AudioImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 7 serializedVersion: 7

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 health: 0
startHealth: 100 startHealth: 100
CurrentNumEnemies: 0 CurrentNumEnemies: 0
Volume: 10
--- !u!114 &6434302952035194364 --- !u!114 &6434302952035194364
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -69,6 +70,8 @@ MonoBehaviour:
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
audioLibrary: {fileID: 11400000, guid: 33d9499f0cd319b2eab27cf0f8e39a40, type: 2} audioLibrary: {fileID: 11400000, guid: 33d9499f0cd319b2eab27cf0f8e39a40, type: 2}
mixer: {fileID: 24300002, guid: 8cf15f9ce587aa00ea29d786b6dec264, type: 2}
sfxMixer: {fileID: 24300002, guid: bcb05fb4c7c7e785090bc8c2705dd01d, type: 2}
--- !u!114 &4575217513678934597 --- !u!114 &4575217513678934597
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 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_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0} m_CustomReflection: {fileID: 0}
m_Sun: {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 m_UseRadianceAmbientProbe: 0
--- !u!157 &3 --- !u!157 &3
LightmapSettings: LightmapSettings:

View File

@ -3,12 +3,14 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using UnityEngine; using UnityEngine;
using UnityEngine.Audio;
public class AudioManager : MonoBehaviour public class AudioManager : MonoBehaviour
{ {
public static AudioManager Instance; public static AudioManager Instance;
public AudioLibraryObject audioLibrary; public AudioLibraryObject audioLibrary;
public AudioMixerGroup mixer;
public AudioMixerGroup sfxMixer;
private void Awake() private void Awake()
{ {
@ -31,21 +33,21 @@ public class AudioManager : MonoBehaviour
{ {
Debug.LogWarning(clip.name); 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); 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) if (Instance == null)
{ {
@ -59,6 +61,11 @@ public class AudioManager : MonoBehaviour
audioSource.clip = clip; audioSource.clip = clip;
sourceObject.transform.position = sourcePos; sourceObject.transform.position = sourcePos;
sourceObject.transform.parent = Instance.transform; sourceObject.transform.parent = Instance.transform;
audioSource.volume = GameManager.Instance.Volume;
if (music)
audioSource.outputAudioMixerGroup = Instance.mixer;
else
audioSource.outputAudioMixerGroup = Instance.sfxMixer;
if (is3D) if (is3D)
{ {

View File

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

View File

@ -32,7 +32,7 @@ public class MusicManager : MonoBehaviour
if (intensity > prevIntinsity) 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) else if (intensity < prevIntinsity)
{ {