FishPlayer

一个喜欢摸鱼的废物

0%

Unity编辑器内静音Wwise

项目引入Wwise以后,相信蛮多人都和我一样,平时不想听游戏声音就想听歌捶码修BUG的。但是Unity原本的mute按钮没法直接直接对Wwise那边做操作。
一开始不知道是搜索引擎的使用姿势不对还是咋的,查了好久都没查出来。导师研究了一下弄了一个版,大家用了感觉都很不错,决定分享出来。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

public static class EditorWwiseManager
{
static bool m_isPaused = false;

static EditorWwiseManager()
{
EditorApplication.update += OnUpdate;
EditorApplication.pauseStateChanged += OnPauseStateChanged;
}

private static void OnPauseStateChanged(PauseState state)
{
switch (state)
{
case PauseState.Paused:
m_isPaused = true;
break;
case PauseState.Unpaused:
m_isPaused = false;
break;
}
}

static void OnUpdate()
{
if (EditorUtility.audioMasterMute && !m_isPaused)
{
AkSoundEngine.Suspend(true);
m_isPaused = true;
}
else if (!EditorUtility.audioMasterMute && m_isPaused)
{
AkSoundEngine.WakeupFromSuspend();
m_isPaused = false;
}
}
}

这样就可以通过Editor SceneView上的mute按钮把Wwise静音,超级方便凹。