diff --git a/Editor/SoundMonitorWindow.cs b/Editor/SoundMonitorWindow.cs index 38c6a08..94e8b86 100644 --- a/Editor/SoundMonitorWindow.cs +++ b/Editor/SoundMonitorWindow.cs @@ -1,5 +1,3 @@ -#if false -using System.Collections.Generic; using UnityEditor; using UnityEngine; using UnityEngine.SceneManagement; @@ -17,8 +15,8 @@ private static void Open() } private ISoundManager soundManager; - - private IList cacheInfos = new List(); + + private ISoundVolumeController volumeController; private void OnEnable() { @@ -31,7 +29,7 @@ private void OnDisable() SceneManager.sceneLoaded -= OnSceneLoaded; EditorApplication.playModeStateChanged -= OnPlayModeStateChanged; } - + private void OnPlayModeStateChanged(PlayModeStateChange change) { switch (change) @@ -41,55 +39,64 @@ private void OnPlayModeStateChanged(PlayModeStateChange change) break; case PlayModeStateChange.ExitingPlayMode: soundManager = null; + volumeController = null; break; - } + } } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { SearchComponents(); } - + private void SearchComponents() { foreach (var context in FindObjectsOfType()) { - soundManager = context.Container.TryResolve(); - if (soundManager != null) + if (soundManager == null) + soundManager = context.Container.TryResolve(); + + if (volumeController == null) + volumeController = context.Container.TryResolve(); + + if (soundManager != null && volumeController != null) break; } } - + private void OnGUI() { - if (soundManager != null) + if (volumeController != null) + { + EditorGUILayout.LabelField("Volume"); + EditorGUI.indentLevel++; + volumeController.MasterVolume = EditorGUILayout.Slider("Master", volumeController.MasterVolume, 0.0f, 1.0f); + volumeController.BgmVolume = EditorGUILayout.Slider("BGM", volumeController.BgmVolume, 0.0f, 1.0f); + volumeController.SeVolume = EditorGUILayout.Slider("SE", volumeController.SeVolume, 0.0f, 1.0f); + volumeController.VoiceVolume = EditorGUILayout.Slider("Voice", volumeController.VoiceVolume, 0.0f, 1.0f); + EditorGUI.indentLevel--; + } + else { - cacheInfos.Clear(); - soundManager.GetCacheInfos(ref cacheInfos); + EditorGUILayout.LabelField("Not Found ISoundVolumeController."); + } + + EditorGUILayout.Space(); - foreach (var cacheInfo in cacheInfos) + if (soundManager != null) + { + EditorGUILayout.LabelField("Loaded Sounds"); + EditorGUI.indentLevel++; + foreach (var info in soundManager.GetInfos()) { - var lines = cacheInfo.Split('\n'); - EditorGUILayout.LabelField(lines[0]); - EditorGUI.indentLevel++; - for (var i = 1; i < lines.Length; i++) - { - var keyValue = lines[i].Split(':'); - if (keyValue.Length >= 2) - EditorGUILayout.TextField(keyValue[0].Trim(), keyValue[1].Trim()); - else if (!string.IsNullOrEmpty(keyValue[0])) - EditorGUILayout.TextField(keyValue[0].Trim()); - else - EditorGUILayout.Space(); - } - EditorGUI.indentLevel--; + EditorGUILayout.LabelField(info); } + EditorGUI.indentLevel--; } else { - EditorGUILayout.LabelField("Not found."); + EditorGUILayout.LabelField("Not Found ISoundManager."); } } } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/Runtime/ADX2/Internal/Adx2SoundManager.cs b/Runtime/ADX2/Internal/Adx2SoundManager.cs index 73685d4..26fde21 100644 --- a/Runtime/ADX2/Internal/Adx2SoundManager.cs +++ b/Runtime/ADX2/Internal/Adx2SoundManager.cs @@ -1,5 +1,6 @@ #if GAMEBASE_ADD_ADX2 using System.Collections.Generic; +using System.Linq; using Gamebase.Loader.Asset; using Gamebase.Utilities; using JetBrains.Annotations; @@ -139,7 +140,9 @@ void ISoundManager.Unload(ISoundPlayer player) players.Remove(player as Adx2SoundPlayer); playerFactory.Despawn(player as Adx2SoundPlayer); } - + + IEnumerable ISoundManager.GetInfos() => cueSheets.Values.Select(x => x.CueSheet.name); + #endregion } } diff --git a/Runtime/ISoundManager.cs b/Runtime/ISoundManager.cs index b515842..5bc8ee6 100644 --- a/Runtime/ISoundManager.cs +++ b/Runtime/ISoundManager.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using UniRx.Async; namespace Gamebase.Sound @@ -11,5 +12,7 @@ public interface ISoundManager UniTask Load(string path); void Unload(ISoundPlayer player); + + IEnumerable GetInfos(); } } \ No newline at end of file diff --git a/Runtime/MasterAudio/DynamicSoundGroupCreatorReference.cs b/Runtime/MasterAudio/DynamicSoundGroupCreatorReference.cs index a1b7adb..29062b5 100644 --- a/Runtime/MasterAudio/DynamicSoundGroupCreatorReference.cs +++ b/Runtime/MasterAudio/DynamicSoundGroupCreatorReference.cs @@ -1,4 +1,4 @@ -#if GAMEBASE_ADD_MASTERAUDIO && UNITY_EDITOR +#if GAMEBASE_ADD_MASTERAUDIO using System; using DarkTonic.MasterAudio; using UnityEngine; diff --git a/Runtime/MasterAudio/Internal/MasterAudioManager.cs b/Runtime/MasterAudio/Internal/MasterAudioManager.cs index 303c3a8..d38c0f4 100644 --- a/Runtime/MasterAudio/Internal/MasterAudioManager.cs +++ b/Runtime/MasterAudio/Internal/MasterAudioManager.cs @@ -1,5 +1,6 @@ #if GAMEBASE_ADD_MASTERAUDIO using System.Collections.Generic; +using System.Linq; using DarkTonic.MasterAudio; using Gamebase.Loader.Asset; using JetBrains.Annotations; @@ -76,7 +77,9 @@ void ISoundManager.Unload(ISoundPlayer player) assetLoader.Unload(sound); soundPacks.Remove(player); } - + + IEnumerable ISoundManager.GetInfos() => soundPacks.Keys.Select(x => x.FileName); + #endregion } } diff --git a/Runtime/NodeCanvas/Actions/DisposeSoundManager.cs b/Runtime/NodeCanvas/Actions/DisposeSoundManager.cs new file mode 100644 index 0000000..0276da2 --- /dev/null +++ b/Runtime/NodeCanvas/Actions/DisposeSoundManager.cs @@ -0,0 +1,19 @@ +#if GAMEBASE_ADD_NODECANVAS +using JetBrains.Annotations; +using NodeCanvas.Framework; +using ParadoxNotion.Design; + +namespace Gamebase.Sound.NodeCanvas.Actions +{ + [PublicAPI] + [Name("Dispose Sound Manager")] + [Category("✫ Gamebase/Sound")] + public sealed class DisposeSoundManager : ActionTask + { + protected override void OnExecute() + { + agent.Manager.Dispose(); + } + } +} +#endif \ No newline at end of file diff --git a/Runtime/NodeCanvas/Actions/DisposeSoundManager.cs.meta b/Runtime/NodeCanvas/Actions/DisposeSoundManager.cs.meta new file mode 100644 index 0000000..eda1f28 --- /dev/null +++ b/Runtime/NodeCanvas/Actions/DisposeSoundManager.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7b27a631413e4d5da1af323f9e15819d +timeCreated: 1587923432 \ No newline at end of file diff --git a/Runtime/Unity/Internal/UnitySoundManager.cs b/Runtime/Unity/Internal/UnitySoundManager.cs index 97e7d73..8b3a08e 100644 --- a/Runtime/Unity/Internal/UnitySoundManager.cs +++ b/Runtime/Unity/Internal/UnitySoundManager.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using Gamebase.Loader.Asset; using JetBrains.Annotations; using UniRx.Async; @@ -70,7 +71,9 @@ void ISoundManager.Unload(ISoundPlayer player) assetLoader.Unload(handle); } } - + + IEnumerable ISoundManager.GetInfos() => soundPacks.Keys.Select(x => x.FileName); + #endregion } } \ No newline at end of file diff --git a/package.json b/package.json index 2348674..8855d6b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.gamebase.sound", "displayName": "Gamebase-Sound", - "version": "1.0.0-preview.5", + "version": "1.0.0-preview.6", "unity": "2018.3", "license": "MIT", "repository": {