浏览代码
Audio System (#90)
Audio System (#90)
* Adding scenesLoader scene * Adding main menu and level 1 scenes for test * Adding loading system * Adding scenes data (still WIP) * SOs for menus and levels and adding scenes * Adding events and listeners for scene loading * Main menu and loading bar scripts * pushing ScenesLoader scene * Main menu scene, added menu disable on start * Added check to avoid loading scene multiple times * Changed to L key instead of space bar for load (space used to jump) * Clean * Added clear lists option and tweaks on MM and ScenesLoader scenes * Adjustments on scene loading * Added level 2 and level end trigger in level 1 * Added new obstacle material for lvl2 and tagged Player * Added custom inspector for GameScene ScriptableObjects It improves workflow and minimizes user error by allowing a designer to pick scenes from a list instead of typing their name manually * Updated GameSceneEditor class * Added new obstacle mate.../main
GitHub
4 年前
当前提交
2907b6c8
共有 71 个文件被更改,包括 8368 次插入 和 0 次删除
-
8UOP1_Project/Assets/Audio.meta
-
142UOP1_Project/Assets/Prefabs/AudioManager.prefab
-
7UOP1_Project/Assets/Prefabs/AudioManager.prefab.meta
-
142UOP1_Project/Assets/Prefabs/SoundEmitter.prefab
-
7UOP1_Project/Assets/Prefabs/SoundEmitter.prefab.meta
-
8UOP1_Project/Assets/ScriptableObjects/Audio.meta
-
14UOP1_Project/Assets/ScriptableObjects/Events/RegularSFX.asset
-
8UOP1_Project/Assets/ScriptableObjects/Events/RegularSFX.asset.meta
-
8UOP1_Project/Assets/Scripts/Audio.meta
-
17UOP1_Project/Assets/Scripts/Events/ScriptableObjects/AudioCueEventSO.cs
-
11UOP1_Project/Assets/Scripts/Events/ScriptableObjects/AudioCueEventSO.cs.meta
-
8UOP1_Project/Assets/Scripts/Sound.meta
-
8UOP1_Project/Assets/Settings/Audio.meta
-
8UOP1_Project/Assets/Audio/Test_Music.meta
-
22UOP1_Project/Assets/Audio/Test_Music/TestSong_Mystery.mp3.meta
-
1001UOP1_Project/Assets/Audio/Test_Music/TestSong_Retro.mp3
-
22UOP1_Project/Assets/Audio/Test_Music/TestSong_Retro.mp3.meta
-
8UOP1_Project/Assets/Audio/Test_SFX.meta
-
1001UOP1_Project/Assets/Audio/Test_SFX/TestSFX_ChooChoo.wav
-
22UOP1_Project/Assets/Audio/Test_SFX/TestSFX_ChooChoo.wav.meta
-
1001UOP1_Project/Assets/Audio/Test_SFX/TestSFX_Flames_Loop.wav
-
22UOP1_Project/Assets/Audio/Test_SFX/TestSFX_Flames_Loop.wav.meta
-
1001UOP1_Project/Assets/Audio/Test_SFX/TestSFX_Magic.wav
-
22UOP1_Project/Assets/Audio/Test_SFX/TestSFX_Magic.wav.meta
-
895UOP1_Project/Assets/Audio/Test_SFX/TestSFX_Mechanism0.wav
-
22UOP1_Project/Assets/Audio/Test_SFX/TestSFX_Mechanism0.wav.meta
-
690UOP1_Project/Assets/Audio/Test_SFX/TestSFX_Mechanism1.wav
-
22UOP1_Project/Assets/Audio/Test_SFX/TestSFX_Mechanism1.wav.meta
-
479UOP1_Project/Assets/Audio/Test_SFX/TestSFX_Mechanism2.wav
-
22UOP1_Project/Assets/Audio/Test_SFX/TestSFX_Mechanism2.wav.meta
-
1001UOP1_Project/Assets/Audio/Test_SFX/TestSFX_Mechanism3.wav
-
22UOP1_Project/Assets/Audio/Test_SFX/TestSFX_Mechanism3.wav.meta
-
8UOP1_Project/Assets/ScriptableObjects/Audio/AudioConfigurations.meta
-
34UOP1_Project/Assets/ScriptableObjects/Audio/AudioConfigurations/DefaultConfiguration.asset
-
8UOP1_Project/Assets/ScriptableObjects/Audio/AudioConfigurations/DefaultConfiguration.asset.meta
-
8UOP1_Project/Assets/ScriptableObjects/Audio/AudioCues.meta
-
22UOP1_Project/Assets/ScriptableObjects/Audio/AudioCues/SFX_4_Mechanisms.asset
-
8UOP1_Project/Assets/ScriptableObjects/Audio/AudioCues/SFX_4_Mechanisms.asset.meta
-
25UOP1_Project/Assets/ScriptableObjects/Audio/AudioCues/SFX_4_Mechanisms_Magic.asset
-
8UOP1_Project/Assets/ScriptableObjects/Audio/AudioCues/SFX_4_Mechanisms_Magic.asset.meta
-
19UOP1_Project/Assets/ScriptableObjects/Audio/AudioCues/SFX_Fire_looping.asset
-
8UOP1_Project/Assets/ScriptableObjects/Audio/AudioCues/SFX_Fire_looping.asset.meta
-
8UOP1_Project/Assets/Scripts/Audio/AudioData.meta
-
26UOP1_Project/Assets/Scripts/Audio/AudioData/AudioConfigurationSO.cs
-
11UOP1_Project/Assets/Scripts/Audio/AudioData/AudioConfigurationSO.cs.meta
-
19UOP1_Project/Assets/Scripts/Audio/AudioData/AudioCue.cs
-
11UOP1_Project/Assets/Scripts/Audio/AudioData/AudioCue.cs.meta
-
88UOP1_Project/Assets/Scripts/Audio/AudioData/AudioCueSO.cs
-
11UOP1_Project/Assets/Scripts/Audio/AudioData/AudioCueSO.cs.meta
-
93UOP1_Project/Assets/Scripts/Audio/AudioManager.cs
-
11UOP1_Project/Assets/Scripts/Audio/AudioManager.cs.meta
-
8UOP1_Project/Assets/Scripts/Audio/SoundEmitters.meta
-
100UOP1_Project/Assets/Scripts/Audio/SoundEmitters/SoundEmitter.cs
-
11UOP1_Project/Assets/Scripts/Audio/SoundEmitters/SoundEmitter.cs.meta
-
20UOP1_Project/Assets/Scripts/Audio/SoundEmitters/SoundEmitterFactorySO.cs
-
11UOP1_Project/Assets/Scripts/Audio/SoundEmitters/SoundEmitterFactorySO.cs.meta
-
37UOP1_Project/Assets/Scripts/Audio/SoundEmitters/SoundEmitterPoolSO.cs
-
11UOP1_Project/Assets/Scripts/Audio/SoundEmitters/SoundEmitterPoolSO.cs.meta
-
65UOP1_Project/Assets/Settings/Audio/DefaultAudioMixer.mixer
-
8UOP1_Project/Assets/Settings/Audio/DefaultAudioMixer.mixer.meta
|
|||
fileFormatVersion: 2 |
|||
guid: a10398fdf145a4f48abf751285622ff0 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!1 &3460372781639194038 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 3460372781639194033} |
|||
- component: {fileID: 3460372781639194032} |
|||
- component: {fileID: 1196505008} |
|||
m_Layer: 0 |
|||
m_Name: AudioManager |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!4 &3460372781639194033 |
|||
Transform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 3460372781639194038} |
|||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} |
|||
m_LocalPosition: {x: 0, y: 0, z: 0} |
|||
m_LocalScale: {x: 1, y: 1, z: 1} |
|||
m_Children: [] |
|||
m_Father: {fileID: 0} |
|||
m_RootOrder: 0 |
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
|||
--- !u!82 &3460372781639194032 |
|||
AudioSource: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 3460372781639194038} |
|||
m_Enabled: 1 |
|||
serializedVersion: 4 |
|||
OutputAudioMixerGroup: {fileID: 0} |
|||
m_audioClip: {fileID: 0} |
|||
m_PlayOnAwake: 1 |
|||
m_Volume: 1 |
|||
m_Pitch: 1 |
|||
Loop: 0 |
|||
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!114 &1196505008 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 3460372781639194038} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: 3f135272f147a0245ad3784829d58618, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|
|||
fileFormatVersion: 2 |
|||
guid: 21a077afbb8e3dc49b65102d8ede3b05 |
|||
PrefabImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!1 &2739658042293639765 |
|||
GameObject: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
serializedVersion: 6 |
|||
m_Component: |
|||
- component: {fileID: 1714241928462444866} |
|||
- component: {fileID: 1935577423453637269} |
|||
- component: {fileID: 2205507954595888356} |
|||
m_Layer: 0 |
|||
m_Name: SoundEmitter |
|||
m_TagString: Untagged |
|||
m_Icon: {fileID: 0} |
|||
m_NavMeshLayer: 0 |
|||
m_StaticEditorFlags: 0 |
|||
m_IsActive: 1 |
|||
--- !u!4 &1714241928462444866 |
|||
Transform: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 2739658042293639765} |
|||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} |
|||
m_LocalPosition: {x: 584.5564, y: 427.41565, z: 46.807434} |
|||
m_LocalScale: {x: 1, y: 1, z: 1} |
|||
m_Children: [] |
|||
m_Father: {fileID: 0} |
|||
m_RootOrder: 0 |
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} |
|||
--- !u!82 &1935577423453637269 |
|||
AudioSource: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 2739658042293639765} |
|||
m_Enabled: 1 |
|||
serializedVersion: 4 |
|||
OutputAudioMixerGroup: {fileID: 0} |
|||
m_audioClip: {fileID: 0} |
|||
m_PlayOnAwake: 1 |
|||
m_Volume: 1 |
|||
m_Pitch: 1 |
|||
Loop: 0 |
|||
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!114 &2205507954595888356 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 2739658042293639765} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: 4189beafe49762549ac23e37feb5f28c, type: 3} |
|||
m_Name: |
|||
m_EditorClassIdentifier: |
|
|||
fileFormatVersion: 2 |
|||
guid: b6374dcc6ce276541949038bf7979cc1 |
|||
PrefabImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: e7009e3e2b334b548a409f0767264d4c |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!114 &11400000 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 0} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: d7847b6caa8e5464c80cd90a8cc33a19, type: 3} |
|||
m_Name: RegularSFX_Cue |
|||
m_EditorClassIdentifier: |
|
|||
fileFormatVersion: 2 |
|||
guid: c3c796b7c31ad3647a3fbae42e74764e |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 4f08400344089654d8a20662d92ca58c |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
using System.Collections; |
|||
using UnityEngine.Events; |
|||
|
|||
/// <summary>
|
|||
/// Event on which <c>AudioCue</c> components send a message to play SFX and music. <c>AudioManager</c> listens on these events, and actually plays the sound.
|
|||
/// </summary>
|
|||
[CreateAssetMenu(menuName = "Game Event/Audio Cue")] |
|||
public class AudioCueEventSO : ScriptableObject |
|||
{ |
|||
public UnityAction<AudioCueSO, AudioConfigurationSO, Vector3> eventRaised; |
|||
|
|||
public void Raise(AudioCueSO audioCue, AudioConfigurationSO audioConfiguration, Vector3 positionInSpace) |
|||
{ |
|||
eventRaised.Invoke(audioCue, audioConfiguration, positionInSpace); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: d7847b6caa8e5464c80cd90a8cc33a19 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 7f027bef4434b504f9b49753067f5ea1 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: d7138a22104e988468b519b0e6405bd2 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 9eb3530c91890914bb24b4519e19a44c |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 51f3b5733102ff746aec062bd88e2f0c |
|||
AudioImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 6 |
|||
defaultSettings: |
|||
loadType: 0 |
|||
sampleRateSetting: 0 |
|||
sampleRateOverride: 44100 |
|||
compressionFormat: 1 |
|||
quality: 1 |
|||
conversionMode: 0 |
|||
platformSettingOverrides: {} |
|||
forceToMono: 0 |
|||
normalize: 1 |
|||
preloadAudioData: 1 |
|||
loadInBackground: 0 |
|||
ambisonic: 0 |
|||
3D: 1 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
UOP1_Project/Assets/Audio/Test_Music/TestSong_Retro.mp3
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 544ed3737343a2e469b9767d2deec067 |
|||
AudioImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 6 |
|||
defaultSettings: |
|||
loadType: 0 |
|||
sampleRateSetting: 0 |
|||
sampleRateOverride: 44100 |
|||
compressionFormat: 1 |
|||
quality: 1 |
|||
conversionMode: 0 |
|||
platformSettingOverrides: {} |
|||
forceToMono: 0 |
|||
normalize: 1 |
|||
preloadAudioData: 1 |
|||
loadInBackground: 0 |
|||
ambisonic: 0 |
|||
3D: 1 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: f7a1cce984e1dad4fa8cfe8d427183b8 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
UOP1_Project/Assets/Audio/Test_SFX/TestSFX_ChooChoo.wav
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 8b7037330a72ab94693661c7b6688cf6 |
|||
AudioImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 6 |
|||
defaultSettings: |
|||
loadType: 0 |
|||
sampleRateSetting: 0 |
|||
sampleRateOverride: 44100 |
|||
compressionFormat: 1 |
|||
quality: 1 |
|||
conversionMode: 0 |
|||
platformSettingOverrides: {} |
|||
forceToMono: 0 |
|||
normalize: 1 |
|||
preloadAudioData: 1 |
|||
loadInBackground: 0 |
|||
ambisonic: 0 |
|||
3D: 1 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
UOP1_Project/Assets/Audio/Test_SFX/TestSFX_Flames_Loop.wav
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 9ecce15a7e9fa5e4eb19a867283bfe70 |
|||
AudioImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 6 |
|||
defaultSettings: |
|||
loadType: 0 |
|||
sampleRateSetting: 0 |
|||
sampleRateOverride: 44100 |
|||
compressionFormat: 1 |
|||
quality: 1 |
|||
conversionMode: 0 |
|||
platformSettingOverrides: {} |
|||
forceToMono: 0 |
|||
normalize: 1 |
|||
preloadAudioData: 1 |
|||
loadInBackground: 0 |
|||
ambisonic: 0 |
|||
3D: 1 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
UOP1_Project/Assets/Audio/Test_SFX/TestSFX_Magic.wav
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 203476aa43e456e48a9d4b8a17f72f58 |
|||
AudioImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 6 |
|||
defaultSettings: |
|||
loadType: 0 |
|||
sampleRateSetting: 0 |
|||
sampleRateOverride: 44100 |
|||
compressionFormat: 1 |
|||
quality: 1 |
|||
conversionMode: 0 |
|||
platformSettingOverrides: {} |
|||
forceToMono: 0 |
|||
normalize: 1 |
|||
preloadAudioData: 1 |
|||
loadInBackground: 0 |
|||
ambisonic: 0 |
|||
3D: 1 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
895
UOP1_Project/Assets/Audio/Test_SFX/TestSFX_Mechanism0.wav
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 60c2068e770cc2049ae9e26f1b010743 |
|||
AudioImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 6 |
|||
defaultSettings: |
|||
loadType: 0 |
|||
sampleRateSetting: 0 |
|||
sampleRateOverride: 44100 |
|||
compressionFormat: 1 |
|||
quality: 1 |
|||
conversionMode: 0 |
|||
platformSettingOverrides: {} |
|||
forceToMono: 0 |
|||
normalize: 1 |
|||
preloadAudioData: 1 |
|||
loadInBackground: 0 |
|||
ambisonic: 0 |
|||
3D: 1 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
690
UOP1_Project/Assets/Audio/Test_SFX/TestSFX_Mechanism1.wav
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 57fe0a526d29da941965b75399970e2c |
|||
AudioImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 6 |
|||
defaultSettings: |
|||
loadType: 0 |
|||
sampleRateSetting: 0 |
|||
sampleRateOverride: 44100 |
|||
compressionFormat: 1 |
|||
quality: 1 |
|||
conversionMode: 0 |
|||
platformSettingOverrides: {} |
|||
forceToMono: 0 |
|||
normalize: 1 |
|||
preloadAudioData: 1 |
|||
loadInBackground: 0 |
|||
ambisonic: 0 |
|||
3D: 1 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
479
UOP1_Project/Assets/Audio/Test_SFX/TestSFX_Mechanism2.wav
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: ba3514f2c66f76d4a8d06ffeb16fe99f |
|||
AudioImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 6 |
|||
defaultSettings: |
|||
loadType: 0 |
|||
sampleRateSetting: 0 |
|||
sampleRateOverride: 44100 |
|||
compressionFormat: 1 |
|||
quality: 1 |
|||
conversionMode: 0 |
|||
platformSettingOverrides: {} |
|||
forceToMono: 0 |
|||
normalize: 1 |
|||
preloadAudioData: 1 |
|||
loadInBackground: 0 |
|||
ambisonic: 0 |
|||
3D: 1 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
UOP1_Project/Assets/Audio/Test_SFX/TestSFX_Mechanism3.wav
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 0ef6ad8b7422bb84090b2494e510a968 |
|||
AudioImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 6 |
|||
defaultSettings: |
|||
loadType: 0 |
|||
sampleRateSetting: 0 |
|||
sampleRateOverride: 44100 |
|||
compressionFormat: 1 |
|||
quality: 1 |
|||
conversionMode: 0 |
|||
platformSettingOverrides: {} |
|||
forceToMono: 0 |
|||
normalize: 1 |
|||
preloadAudioData: 1 |
|||
loadInBackground: 0 |
|||
ambisonic: 0 |
|||
3D: 1 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 057b3fc161e0305429bd219f4e6d54a8 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!114 &11400000 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 0} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: b357a35b19afa6e4ca9ed9cc1830f6de, type: 3} |
|||
m_Name: DefaultConfiguration |
|||
m_EditorClassIdentifier: |
|||
OutputAudioMixerGroup: {fileID: 24300002, guid: 548a7f001ca6d3d4cb67c8edf84f62a3, |
|||
type: 2} |
|||
Mute: 0 |
|||
BypassEffects: 0 |
|||
BypassListenerEffects: 0 |
|||
BypassReverbZones: 0 |
|||
Loop: 0 |
|||
Priority: 128 |
|||
Volume: 1 |
|||
Pitch: 1 |
|||
PanStereo: 0 |
|||
SpatialBlend: 0 |
|||
ReverbZoneMix: 1 |
|||
DopplerLevel: 1 |
|||
Spread: 0 |
|||
RolloffMode: 0 |
|||
MinDistance: 1 |
|||
MaxDistance: 500 |
|||
IgnoreListenerVolume: 0 |
|||
IgnoreListenerPause: 0 |
|
|||
fileFormatVersion: 2 |
|||
guid: 8d4217c8fabf9824490196f34baf326a |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 5f2cf5ebc4f20cd49841352e66674c5f |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!114 &11400000 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 0} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: 08e854ccd8588da4694c3ae040c10c5e, type: 3} |
|||
m_Name: SFX_4_Mechanisms |
|||
m_EditorClassIdentifier: |
|||
_looping: 0 |
|||
_audioClipGroups: |
|||
- sequenceMode: 1 |
|||
audioClips: |
|||
- {fileID: 8300000, guid: 60c2068e770cc2049ae9e26f1b010743, type: 3} |
|||
- {fileID: 8300000, guid: 57fe0a526d29da941965b75399970e2c, type: 3} |
|||
- {fileID: 8300000, guid: ba3514f2c66f76d4a8d06ffeb16fe99f, type: 3} |
|||
- {fileID: 8300000, guid: 0ef6ad8b7422bb84090b2494e510a968, type: 3} |
|
|||
fileFormatVersion: 2 |
|||
guid: cd2aedc39ac8b734bb291c84c3d68a97 |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!114 &11400000 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 0} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: 08e854ccd8588da4694c3ae040c10c5e, type: 3} |
|||
m_Name: SFX_4_Mechanisms_Magic |
|||
m_EditorClassIdentifier: |
|||
_looping: 0 |
|||
_audioClipGroups: |
|||
- sequenceMode: 1 |
|||
audioClips: |
|||
- {fileID: 8300000, guid: 60c2068e770cc2049ae9e26f1b010743, type: 3} |
|||
- {fileID: 8300000, guid: 57fe0a526d29da941965b75399970e2c, type: 3} |
|||
- {fileID: 8300000, guid: ba3514f2c66f76d4a8d06ffeb16fe99f, type: 3} |
|||
- {fileID: 8300000, guid: 0ef6ad8b7422bb84090b2494e510a968, type: 3} |
|||
- sequenceMode: 0 |
|||
audioClips: |
|||
- {fileID: 8300000, guid: 203476aa43e456e48a9d4b8a17f72f58, type: 3} |
|
|||
fileFormatVersion: 2 |
|||
guid: 68848f118f687254baf4d4e2f4bfbe65 |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!114 &11400000 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 0} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 11500000, guid: 08e854ccd8588da4694c3ae040c10c5e, type: 3} |
|||
m_Name: SFX_Fire_looping |
|||
m_EditorClassIdentifier: |
|||
_looping: 1 |
|||
_audioClipGroups: |
|||
- sequenceMode: 0 |
|||
audioClips: |
|||
- {fileID: 8300000, guid: 9ecce15a7e9fa5e4eb19a867283bfe70, type: 3} |
|
|||
fileFormatVersion: 2 |
|||
guid: 7d37fa2008a49c94caaedbb075cc665c |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 9d68f4cd0a9ef9c4aa26b461fe3b82ad |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
using UnityEngine.Audio; |
|||
|
|||
//TODO: Check which settings we really need at this level
|
|||
[CreateAssetMenu(menuName = "Audio/Audio Configuration")] |
|||
public class AudioConfigurationSO : ScriptableObject |
|||
{ |
|||
public AudioMixerGroup OutputAudioMixerGroup = null; |
|||
public bool Mute = false; |
|||
public bool BypassEffects = false; |
|||
public bool BypassListenerEffects = false; |
|||
public bool BypassReverbZones = false; |
|||
public int Priority = 128; |
|||
public float Volume = 1f; |
|||
public float Pitch = 1f; |
|||
public float PanStereo = 0f; |
|||
public float SpatialBlend = 0f; |
|||
public float ReverbZoneMix = 1f; |
|||
public float DopplerLevel = 1f; |
|||
public float Spread = 0f; |
|||
public AudioRolloffMode RolloffMode = AudioRolloffMode.Logarithmic; |
|||
public float MinDistance = 1f; |
|||
public float MaxDistance = 500f; |
|||
public bool IgnoreListenerVolume = false; |
|||
public bool IgnoreListenerPause = false; |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: b357a35b19afa6e4ca9ed9cc1830f6de |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
|
|||
/// <summary>
|
|||
/// Simple implementation of a MonoBehaviour that is able to request a sound being played by the <c>AudioManager</c>.
|
|||
/// It fires an event on an <c>AudioCueEventSO</c> which acts as a channel, that the <c>AudioManager</c> will pick up and play.
|
|||
/// </summary>
|
|||
public class AudioCue : MonoBehaviour |
|||
{ |
|||
[SerializeField] private AudioCueSO _audioCue = default; |
|||
[SerializeField] private AudioCueEventSO _audioCueEventChannel = default; |
|||
[SerializeField] private AudioConfigurationSO _audioConfiguration = default; |
|||
|
|||
public void PlayAudioCue() |
|||
{ |
|||
_audioCueEventChannel.Raise(_audioCue, _audioConfiguration, transform.position); |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 54f92f965dbe44449b252b814ddc7137 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using UnityEngine; |
|||
|
|||
/// <summary>
|
|||
/// A collection of audio clips that are played in parallel, and support randomisation.
|
|||
/// </summary>
|
|||
[CreateAssetMenu(fileName = "newAudioCue", menuName = "Audio/Audio Cue")] |
|||
public class AudioCueSO : ScriptableObject |
|||
{ |
|||
public bool looping = false; |
|||
[SerializeField] private AudioClipsGroup[] _audioClipGroups = default; |
|||
|
|||
public AudioClip[] GetClips() |
|||
{ |
|||
int numberOfClips = _audioClipGroups.Length; |
|||
AudioClip[] resultingClips = new AudioClip[numberOfClips]; |
|||
|
|||
for (int i = 0; i < numberOfClips; i++) |
|||
{ |
|||
resultingClips[i] = _audioClipGroups[i].GetNextClip(); |
|||
} |
|||
|
|||
return resultingClips; |
|||
} |
|||
} |
|||
|
|||
|
|||
/// <summary>
|
|||
/// Represents a group of AudioClips that can be treated as one, and provides automatic randomisation or sequencing based on the <c>SequenceMode</c> value.
|
|||
/// </summary>
|
|||
[Serializable] |
|||
public class AudioClipsGroup |
|||
{ |
|||
public SequenceMode sequenceMode = SequenceMode.RandomNoImmediateRepeat; |
|||
public AudioClip[] audioClips; |
|||
|
|||
private int _nextClipToPlay = -1; |
|||
private int _lastClipPlayed = -1; |
|||
|
|||
/// <summary>
|
|||
/// Chooses the next clip in the sequence, either following the order or randomly.
|
|||
/// </summary>
|
|||
/// <returns>A reference to an AudioClip</returns>
|
|||
public AudioClip GetNextClip() |
|||
{ |
|||
// Fast out if there is only one clip to play
|
|||
if(audioClips.Length == 1) |
|||
return audioClips[0]; |
|||
|
|||
if(_nextClipToPlay == -1) |
|||
{ |
|||
// Index needs to be initialised: 0 if Sequential, random if otherwise
|
|||
_nextClipToPlay = (sequenceMode == SequenceMode.Sequential) ? 0 : UnityEngine.Random.Range(0, audioClips.Length); |
|||
} |
|||
else |
|||
{ |
|||
// Select next clip index based on the appropriate SequenceMode
|
|||
switch (sequenceMode) |
|||
{ |
|||
case SequenceMode.Random: |
|||
_nextClipToPlay = UnityEngine.Random.Range(0, audioClips.Length); |
|||
break; |
|||
|
|||
case SequenceMode.RandomNoImmediateRepeat: |
|||
do |
|||
{ |
|||
_nextClipToPlay = UnityEngine.Random.Range(0, audioClips.Length); |
|||
} while (_nextClipToPlay == _lastClipPlayed); |
|||
break; |
|||
|
|||
case SequenceMode.Sequential: |
|||
_nextClipToPlay = (int)Mathf.Repeat(_nextClipToPlay++, audioClips.Length); |
|||
break; |
|||
} |
|||
} |
|||
|
|||
_lastClipPlayed = _nextClipToPlay; |
|||
|
|||
return audioClips[_nextClipToPlay]; |
|||
} |
|||
|
|||
public enum SequenceMode |
|||
{ |
|||
Random, |
|||
RandomNoImmediateRepeat, |
|||
Sequential, |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 08e854ccd8588da4694c3ae040c10c5e |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections; |
|||
using System.Linq; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using UnityEngine.Audio; |
|||
|
|||
public class AudioManager : MonoBehaviour |
|||
{ |
|||
[Tooltip ("Amount of sound emitters created on Start")] |
|||
[SerializeField] private int _initialPoolSize = 1; |
|||
[SerializeField] private SoundEmitter _soundEmitterPrefab = default; |
|||
[Tooltip("The SoundManager listens to this event, fired by objects in any scene, to play SFXs")] |
|||
[SerializeField] private AudioCueEventSO _SFXEvent = default; |
|||
[Tooltip("The SoundManager listens to this event, fired by objects in any scene, to play Music")] |
|||
[SerializeField] private AudioCueEventSO _musicEvent = default; |
|||
|
|||
private SoundEmitterFactorySO _factory; |
|||
private SoundEmitterPoolSO _pool; |
|||
public SoundEmitterPoolSO Pool { get { return _pool; } } |
|||
|
|||
private void Awake() |
|||
{ |
|||
InitPool(); |
|||
|
|||
_SFXEvent.eventRaised += PlayAudioCue; |
|||
} |
|||
|
|||
private void InitPool() |
|||
{ |
|||
_factory = ScriptableObject.CreateInstance<SoundEmitterFactorySO>(); |
|||
_factory.Prefab = _soundEmitterPrefab; |
|||
_factory.Prefab.name = "SoundEmitter Factory"; |
|||
_pool = ScriptableObject.CreateInstance<SoundEmitterPoolSO>(); |
|||
_pool.name = "SoundEmitter Pool"; |
|||
_pool.Factory = _factory; |
|||
_pool.InitialPoolSize = _initialPoolSize; |
|||
} |
|||
|
|||
public static bool SetGroupVolume(AudioMixerGroup group, float volume) |
|||
{ |
|||
return group.audioMixer.SetFloat("Volume", NormalizedToMixerValue(volume)); |
|||
} |
|||
|
|||
public static bool GetGroupVolume(AudioMixerGroup group, out float volume) |
|||
{ |
|||
if(group.audioMixer.GetFloat("Volume", out float rawVolume)){ |
|||
volume = MixerValueNormalized(rawVolume); |
|||
return true; |
|||
} |
|||
volume = default; |
|||
return false; |
|||
} |
|||
|
|||
// Both MixerValueNormalized and NormalizedToMixerValue functions are used for easier transformations when using UI sliders normalized format
|
|||
private static float MixerValueNormalized(float value) |
|||
{ |
|||
return (-(value - 80) / 80) - 1; |
|||
} |
|||
private static float NormalizedToMixerValue(float normalizedValue) |
|||
{ |
|||
return -80 + (normalizedValue * 80); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Plays an AudioCue by requesting the appropriate number of SoundEmitters from the pool.
|
|||
/// </summary>
|
|||
public void PlayAudioCue(AudioCueSO audioCue, AudioConfigurationSO settings, Vector3 position = default) |
|||
{ |
|||
AudioClip[] clipsToPlay = audioCue.GetClips(); |
|||
int nOfClips = clipsToPlay.Length; |
|||
|
|||
for (int i = 0; i < nOfClips; i++) |
|||
{ |
|||
SoundEmitter soundEmitter = _pool.Request(); |
|||
if (soundEmitter != null) |
|||
{ |
|||
soundEmitter.PlaySound(clipsToPlay[i], settings, audioCue.looping, position); |
|||
if(audioCue.looping) |
|||
soundEmitter.OnSoundFinishedPlaying += OnSoundEmitterFinishedPlaying; |
|||
} |
|||
} |
|||
|
|||
//TODO: Save the SoundEmitters that were activated, to be able to stop them if needed
|
|||
} |
|||
|
|||
private void OnSoundEmitterFinishedPlaying(SoundEmitter soundEmitter) |
|||
{ |
|||
soundEmitter.OnSoundFinishedPlaying -= OnSoundEmitterFinishedPlaying; |
|||
Pool.Return(soundEmitter); |
|||
} |
|||
|
|||
//TODO: Add methods to play and cross-fade music, or to play individual sounds?
|
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 7dcf69f82f8783049ab749ba8f527f89 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: d399977051a4b9d4f997d124d2d41cf6 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using UnityEngine.Audio; |
|||
using UOP1.Pool; |
|||
using System; |
|||
using UnityEngine.Events; |
|||
|
|||
[RequireComponent (typeof(AudioSource))] |
|||
public class SoundEmitter : MonoBehaviour, IPoolable |
|||
{ |
|||
private AudioSource _audioSource; |
|||
private float _lastUseTimestamp = 0; |
|||
|
|||
public event UnityAction<SoundEmitter> OnSoundFinishedPlaying; |
|||
|
|||
private void Awake() |
|||
{ |
|||
_audioSource = this.GetComponent<AudioSource>(); |
|||
_audioSource.playOnAwake = false; |
|||
} |
|||
|
|||
public void OnRequest() { } |
|||
|
|||
public void OnReturn(Action onReturned) |
|||
{ |
|||
StopSound(); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Instructs the AudioSource to play a single clip, with optional looping, in a position in 3D space.
|
|||
/// </summary>
|
|||
/// <param name="clip"></param>
|
|||
/// <param name="settings"></param>
|
|||
/// <param name="hasToLoop"></param>
|
|||
/// <param name="position"></param>
|
|||
public void PlaySound(AudioClip clip, AudioConfigurationSO settings, bool hasToLoop, Vector3 position = default) |
|||
{ |
|||
_audioSource.clip = clip; |
|||
ApplySettings(_audioSource, settings); |
|||
_audioSource.transform.position = position; |
|||
_audioSource.loop = hasToLoop; |
|||
_audioSource.Play(); |
|||
|
|||
if (!hasToLoop) |
|||
{ |
|||
StartCoroutine(FinishedPlaying(clip.length)); |
|||
} |
|||
} |
|||
|
|||
private void ApplySettings(AudioSource source, AudioConfigurationSO settings) |
|||
{ |
|||
source.outputAudioMixerGroup = settings.OutputAudioMixerGroup; |
|||
source.mute = settings.Mute; |
|||
source.bypassEffects = settings.BypassEffects; |
|||
source.bypassListenerEffects = settings.BypassListenerEffects; |
|||
source.bypassReverbZones = settings.BypassReverbZones; |
|||
source.priority = settings.Priority; |
|||
source.volume = settings.Volume; |
|||
source.pitch = settings.Pitch; |
|||
source.panStereo = settings.PanStereo; |
|||
source.spatialBlend = settings.SpatialBlend; |
|||
source.reverbZoneMix = settings.ReverbZoneMix; |
|||
source.dopplerLevel = settings.DopplerLevel; |
|||
source.spread = settings.Spread; |
|||
source.rolloffMode = settings.RolloffMode; |
|||
source.minDistance = settings.MinDistance; |
|||
source.maxDistance = settings.MaxDistance; |
|||
source.ignoreListenerVolume = settings.IgnoreListenerVolume; |
|||
source.ignoreListenerPause = settings.IgnoreListenerPause; |
|||
} |
|||
|
|||
public void StopSound() |
|||
{ |
|||
_lastUseTimestamp = Time.realtimeSinceStartup; |
|||
_audioSource.Stop(); |
|||
} |
|||
|
|||
public bool IsInUse() |
|||
{ |
|||
return _audioSource.isPlaying; |
|||
} |
|||
|
|||
public bool IsLooping() |
|||
{ |
|||
return _audioSource.loop; |
|||
} |
|||
|
|||
public float LastUseTimestamp() |
|||
{ |
|||
return _lastUseTimestamp; |
|||
} |
|||
|
|||
IEnumerator FinishedPlaying(float clipLength) |
|||
{ |
|||
yield return new WaitForSeconds(clipLength); |
|||
|
|||
OnSoundFinishedPlaying.Invoke(this); // The AudioManager will pick this up
|
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 4189beafe49762549ac23e37feb5f28c |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
using UOP1.Factory; |
|||
|
|||
[CreateAssetMenu(fileName = "NewSoundEmitterFactory", menuName = "Factory/SoundEmitter Factory")] |
|||
public class SoundEmitterFactorySO : ComponentFactorySO<SoundEmitter> |
|||
{ |
|||
[SerializeField] |
|||
private SoundEmitter _prefab = default; |
|||
|
|||
public override SoundEmitter Prefab { |
|||
get |
|||
{ |
|||
return _prefab; |
|||
} |
|||
set |
|||
{ |
|||
_prefab = value; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: f04e493d0e3149245bc4d6979f603110 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine; |
|||
using System.Linq; |
|||
using UOP1.Pool; |
|||
using UOP1.Factory; |
|||
|
|||
[CreateAssetMenu(fileName = "NewSoundEmitterPool", menuName = "Pool/SoundEmitter Pool")] |
|||
public class SoundEmitterPoolSO : ComponentPoolSO<SoundEmitter> |
|||
{ |
|||
[SerializeField] |
|||
private SoundEmitterFactorySO _factory; |
|||
[SerializeField] |
|||
private int _initialPoolSize; |
|||
|
|||
public override IFactory<SoundEmitter> Factory |
|||
{ |
|||
get |
|||
{ |
|||
return _factory; |
|||
} |
|||
set |
|||
{ |
|||
_factory = value as SoundEmitterFactorySO; |
|||
} |
|||
} |
|||
|
|||
public override int InitialPoolSize |
|||
{ |
|||
get |
|||
{ |
|||
return _initialPoolSize; |
|||
} |
|||
set |
|||
{ |
|||
_initialPoolSize = value; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: abd55e716171ecc4daf19691871d6ee1 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%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: DefaultAudioMixer |
|||
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: [] |
|||
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: deb5bf4eb8d0dc044a6b4d78ed072bf1 |
|||
m_Children: [] |
|||
m_Volume: 9271f6921315a7245b91413294248994 |
|||
m_Pitch: faf7d9b6bb1b169458d96a38e2e184cf |
|||
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: ca8500e31f4c32d4f9fd1fb8a75f341c |
|||
m_EffectName: Attenuation |
|||
m_MixLevel: a86e867ad49755641adecd582f35ed30 |
|||
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: d2c2ea162004da549b54501f768d5652 |
|||
m_FloatValues: {} |
|||
m_TransitionOverrides: {} |
|
|||
fileFormatVersion: 2 |
|||
guid: 548a7f001ca6d3d4cb67c8edf84f62a3 |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
部分文件因为文件数量过多而无法显示
撰写
预览
正在加载...
取消
保存
Reference in new issue