diff --git a/MapStation.Common/Runtime/GameAudio.cs b/MapStation.Common/Runtime/GameAudio.cs new file mode 100644 index 00000000..eef25d70 --- /dev/null +++ b/MapStation.Common/Runtime/GameAudio.cs @@ -0,0 +1,29 @@ +using Reptile; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; + +namespace MapStation.Common.Runtime { + [RequireComponent(typeof(AudioSource))] + public class GameAudio : MonoBehaviour { + public enum AudioTypes { + Master = 0, + Music = 4, + SFX = 1, + UI = 2, + Gameplay = 3, + Voices = 5, + Ambience = 6 + } + public AudioTypes AudioType = AudioTypes.Gameplay; +#if BEPINEX + private void Awake() { + var audioSource = GetComponent(); + audioSource.outputAudioMixerGroup = Core.Instance.AudioManager.mixerGroups[(int) AudioType]; + } +#endif + } +} diff --git a/MapStation.Common/Runtime/GameAudio.cs.meta b/MapStation.Common/Runtime/GameAudio.cs.meta new file mode 100644 index 00000000..03798c4f --- /dev/null +++ b/MapStation.Common/Runtime/GameAudio.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 128b8b6b497f5054a8d5dd64ea15a2e1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/MapStation.Tools/Assets/MapComponents/Ambient Sound.prefab b/MapStation.Tools/Assets/MapComponents/Audio Source.prefab similarity index 52% rename from MapStation.Tools/Assets/MapComponents/Ambient Sound.prefab rename to MapStation.Tools/Assets/MapComponents/Audio Source.prefab index 4c9f3757..0c71fc7b 100644 --- a/MapStation.Tools/Assets/MapComponents/Ambient Sound.prefab +++ b/MapStation.Tools/Assets/MapComponents/Audio Source.prefab @@ -1,6 +1,6 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: ---- !u!1 &5531776540454774869 +--- !u!1 &911695850910785175 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -8,58 +8,71 @@ GameObject: m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 1075615974772501728} - - component: {fileID: 5884451559065249828} - - component: {fileID: 7512777971387938246} + - component: {fileID: 4902003743957009481} + - component: {fileID: 6726315859376625976} + - component: {fileID: 761963668604459004} m_Layer: 0 - m_Name: Ambient Sound + m_Name: Audio Source m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!4 &1075615974772501728 +--- !u!4 &4902003743957009481 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5531776540454774869} + m_GameObject: {fileID: 911695850910785175} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalPosition: {x: 26.938553, y: 1.185, z: 3.76005} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!82 &5884451559065249828 +--- !u!114 &6726315859376625976 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 911695850910785175} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 128b8b6b497f5054a8d5dd64ea15a2e1, type: 3} + m_Name: + m_EditorClassIdentifier: + AudioType: 3 +--- !u!82 &761963668604459004 AudioSource: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5531776540454774869} + m_GameObject: {fileID: 911695850910785175} m_Enabled: 1 serializedVersion: 4 - OutputAudioMixerGroup: {fileID: 24300000, guid: 2f929fd3a018c48449995bb7f2a1b192, type: 2} + OutputAudioMixerGroup: {fileID: 0} m_audioClip: {fileID: 0} m_PlayOnAwake: 1 m_Volume: 1 m_Pitch: 1 - Loop: 1 + Loop: 0 Mute: 0 Spatialize: 0 SpatializePostEffects: 0 - Priority: 256 - DopplerLevel: 0 + Priority: 128 + DopplerLevel: 1 MinDistance: 1 - MaxDistance: 1.01 + MaxDistance: 500 Pan2D: 0 - rolloffMode: 2 + rolloffMode: 0 BypassEffects: 0 - BypassListenerEffects: 1 - BypassReverbZones: 1 + BypassListenerEffects: 0 + BypassReverbZones: 0 rolloffCustomCurve: serializedVersion: 2 m_Curve: @@ -129,67 +142,3 @@ AudioSource: m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 ---- !u!114 &7512777971387938246 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 5531776540454774869} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: d3f53950e5e641f459d8726da39a49ff, type: 3} - m_Name: - m_EditorClassIdentifier: - components: - rid: 6810966811538882560 - references: - version: 2 - RefIds: - - rid: -2 - type: {class: , ns: , asm: } - - rid: 6810966811538882560 - type: {class: VanillaAssetReferenceV2/SList_Components, ns: MapStation.Common.VanillaAssets, asm: MapStation.Common} - data: - linkedList: - rid: 6810966811538882561 - items: - - rid: 6810966811538882562 - - rid: 6810966811538882561 - type: {class: Node, ns: MapStation.Common.Serialization, asm: MapStation.Common} - data: - value: - rid: 6810966811538882562 - next: - rid: -2 - - rid: 6810966811538882562 - type: {class: ComponentEntry, ns: MapStation.Common.VanillaAssets, asm: MapStation.Common} - data: - Component: {fileID: 5884451559065249828} - fields: - rid: 6810966811538882563 - - rid: 6810966811538882563 - type: {class: ComponentEntry/SList_FieldEntry, ns: MapStation.Common.VanillaAssets, asm: MapStation.Common} - data: - linkedList: - rid: 6810966811538882566 - items: - - rid: 6810966811538882567 - - rid: 6810966811538882566 - type: {class: Node, ns: MapStation.Common.Serialization, asm: MapStation.Common} - data: - value: - rid: 6810966811538882567 - next: - rid: -2 - - rid: 6810966811538882567 - type: {class: FieldEntry, ns: MapStation.Common.VanillaAssets, asm: MapStation.Common} - data: - Enabled: 1 - AutoSync: 1 - Name: outputAudioMixerGroup - Index: -1 - BundleName: coreassets - Path: Assets/audio/MasterMixer.mixer - SubAssetType: 1 - SubPath: Gameplay diff --git a/MapStation.Tools/Assets/MapComponents/Ambient Sound.prefab.meta b/MapStation.Tools/Assets/MapComponents/Audio Source.prefab.meta similarity index 74% rename from MapStation.Tools/Assets/MapComponents/Ambient Sound.prefab.meta rename to MapStation.Tools/Assets/MapComponents/Audio Source.prefab.meta index 0d8386eb..570bd4cd 100644 --- a/MapStation.Tools/Assets/MapComponents/Ambient Sound.prefab.meta +++ b/MapStation.Tools/Assets/MapComponents/Audio Source.prefab.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 6ac5efa72ac84264986bc2753cc07ebc +guid: 9858fbd944947a442926ddfcfbdb6015 PrefabImporter: externalObjects: {} userData: diff --git a/MapStation.Tools/Editor/Inspectors/GameAudioEditor.cs b/MapStation.Tools/Editor/Inspectors/GameAudioEditor.cs new file mode 100644 index 00000000..3f8fc2cf --- /dev/null +++ b/MapStation.Tools/Editor/Inspectors/GameAudioEditor.cs @@ -0,0 +1,13 @@ +using MapStation.Tools.Editor; +using MapStation.Common.Runtime; +using Reptile; +using UnityEditor; + +[CustomEditor(typeof(GameAudio))] +[CanEditMultipleObjects] +public class GameAudioEditor : Editor { + public override void OnInspectorGUI() { + EditorHelper.MakeDocsButton("Game-Audio"); + DrawDefaultInspector(); + } +} diff --git a/MapStation.Tools/Editor/Inspectors/GameAudioEditor.cs.meta b/MapStation.Tools/Editor/Inspectors/GameAudioEditor.cs.meta new file mode 100644 index 00000000..8e6472e7 --- /dev/null +++ b/MapStation.Tools/Editor/Inspectors/GameAudioEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d97358a18ad9fc441b446b14df42eec5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/MapStation.Tools/Editor/PrefabContextMenu.cs b/MapStation.Tools/Editor/PrefabContextMenu.cs index 5e17b209..cf108829 100644 --- a/MapStation.Tools/Editor/PrefabContextMenu.cs +++ b/MapStation.Tools/Editor/PrefabContextMenu.cs @@ -13,9 +13,9 @@ private enum UnpackMode { private const int Priority = -30; private const string PrefabPathPrefix = "Packages/com.brcmapstation.tools/Assets/MapComponents/"; - [MenuItem("GameObject/" + UIConstants.menuLabel + "/Audio/Ambient Sound", priority = Priority)] - private static void CreateAmbientSound(MenuCommand menuCommand) { - CreatePrefabUnderContext(menuCommand.context, "Ambient Sound", true, UnpackMode.UnpackCompletely); + [MenuItem("GameObject/" + UIConstants.menuLabel + "/Audio/Audio Source", priority = Priority)] + private static void CreateAudioSource(MenuCommand menuCommand) { + CreatePrefabUnderContext(menuCommand.context, "Audio Source", true, UnpackMode.UnpackCompletely); } [MenuItem("GameObject/" + UIConstants.menuLabel + "/Spawners/Respawn Point", priority = Priority)]