Skip to content

Commit

Permalink
Merge pull request #7 from hiyorin/feature/modify
Browse files Browse the repository at this point in the history
Feature/modify
  • Loading branch information
hiyorin authored Apr 26, 2020
2 parents 0e4b14c + 3a2c11a commit ff3be2b
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 36 deletions.
69 changes: 38 additions & 31 deletions Editor/SoundMonitorWindow.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#if false
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.SceneManagement;
Expand All @@ -17,8 +15,8 @@ private static void Open()
}

private ISoundManager soundManager;
private IList<string> cacheInfos = new List<string>();

private ISoundVolumeController volumeController;

private void OnEnable()
{
Expand All @@ -31,7 +29,7 @@ private void OnDisable()
SceneManager.sceneLoaded -= OnSceneLoaded;
EditorApplication.playModeStateChanged -= OnPlayModeStateChanged;
}

private void OnPlayModeStateChanged(PlayModeStateChange change)
{
switch (change)
Expand All @@ -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<SceneContext>())
{
soundManager = context.Container.TryResolve<ISoundManager>();
if (soundManager != null)
if (soundManager == null)
soundManager = context.Container.TryResolve<ISoundManager>();

if (volumeController == null)
volumeController = context.Container.TryResolve<ISoundVolumeController>();

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
}
5 changes: 4 additions & 1 deletion Runtime/ADX2/Internal/Adx2SoundManager.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -139,7 +140,9 @@ void ISoundManager.Unload(ISoundPlayer player)
players.Remove(player as Adx2SoundPlayer);
playerFactory.Despawn(player as Adx2SoundPlayer);
}


IEnumerable<string> ISoundManager.GetInfos() => cueSheets.Values.Select(x => x.CueSheet.name);

#endregion
}
}
Expand Down
3 changes: 3 additions & 0 deletions Runtime/ISoundManager.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Collections.Generic;
using UniRx.Async;

namespace Gamebase.Sound
Expand All @@ -11,5 +12,7 @@ public interface ISoundManager
UniTask<ISoundPlayer> Load(string path);

void Unload(ISoundPlayer player);

IEnumerable<string> GetInfos();
}
}
2 changes: 1 addition & 1 deletion Runtime/MasterAudio/DynamicSoundGroupCreatorReference.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if GAMEBASE_ADD_MASTERAUDIO && UNITY_EDITOR
#if GAMEBASE_ADD_MASTERAUDIO
using System;
using DarkTonic.MasterAudio;
using UnityEngine;
Expand Down
5 changes: 4 additions & 1 deletion Runtime/MasterAudio/Internal/MasterAudioManager.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -76,7 +77,9 @@ void ISoundManager.Unload(ISoundPlayer player)
assetLoader.Unload(sound);
soundPacks.Remove(player);
}


IEnumerable<string> ISoundManager.GetInfos() => soundPacks.Keys.Select(x => x.FileName);

#endregion
}
}
Expand Down
19 changes: 19 additions & 0 deletions Runtime/NodeCanvas/Actions/DisposeSoundManager.cs
Original file line number Diff line number Diff line change
@@ -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<SoundTaskManager>
{
protected override void OnExecute()
{
agent.Manager.Dispose();
}
}
}
#endif
3 changes: 3 additions & 0 deletions Runtime/NodeCanvas/Actions/DisposeSoundManager.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Runtime/Unity/Internal/UnitySoundManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using Gamebase.Loader.Asset;
using JetBrains.Annotations;
using UniRx.Async;
Expand Down Expand Up @@ -70,7 +71,9 @@ void ISoundManager.Unload(ISoundPlayer player)
assetLoader.Unload(handle);
}
}


IEnumerable<string> ISoundManager.GetInfos() => soundPacks.Keys.Select(x => x.FileName);

#endregion
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit ff3be2b

Please sign in to comment.