1、安装fmod profiler
https://www.fmod.com/download#fmodstudiosuite
安装好之后,启动:
2、运行游戏
这里改下初始化的模式,打开profiler,然后输入ip和端口号,默认为127.0.0.1和9264
有时候连不上,需要换个端口号即可。
上面为播放声音之后的节点图,可以检测是否在切场景的时候,有些声音没有回收。
主要如果一个音乐是pause的状态的,则不会被回收。
所以在回收的时候,所以停止声音的时候,要判断其状态是否为pause状态,若是则先将其置为非pause状态,然后在停止:
补充1:
我们可以通过一个event的名字,得到其已经创建了多少个event:
public void SetPause(bool isPause)
{
if (instance.isValid())
{
instance.setPaused(isPause);
//Debug.LogError("setpause instancehashcode=" + instance.GetHashCode());
FMOD.Studio.EventInstance[] array;
eventDescription.getInstanceList(out array);
if(array != null)
{
for (int i = 0; i < array.Length; ++i)
{
if (array[i].isValid()) array[i].setPaused(isPause);
//Debug.LogError("pauseevent=" + Event);
}
}
}
}