Ok, final version. Works with level streaming - although, doesn’t support combining phonon scenes from sublevels.
namespace SteamAudio
{
...
bool HasSceneOnDisk(UWorld* World)
{
FString MapName = StrippedMapName(World->GetMapName());
FString SceneFileName = RuntimePath + MapName + ".phononscene";
IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile();
return PlatformFile.FileExists(*SceneFileName);
}
}
void FSteamAudioModule::OnWorld_Cleanup(UWorld* World, bool bSessionEnded, bool bCleanupResources)
{
if (FAudioDevice* AudioDevice = GEngine->GetActiveAudioDevice())
{
for (TAudioPluginListenerPtr PluginListener : AudioDevice->PluginListeners)
{
PluginListener->OnListenerShutdown(AudioDevice);
}
}
}
void FSteamAudioModule::OnWorld_PostCreation(UWorld* World)
{
bool bHasSceneOnDisk = SteamAudio::HasSceneOnDisk(World);
if (bHasSceneOnDisk)
{
if (FAudioDevice* AudioDevice = GEngine->GetActiveAudioDevice())
{
for (TAudioPluginListenerPtr PluginListener : AudioDevice->PluginListeners)
{
PluginListener->OnListenerInitialize(AudioDevice, World);
}
UE_LOG(LogSteamAudio, Log, TEXT("OnWorld_PostCreation: Audio Device updated for world %s"), *World->GetName());
}
else
{
UE_LOG(LogSteamAudio, Warning, TEXT("OnWorld_PostCreation: Can't get valid Audio Device"));
}
}
else
{
UE_LOG(LogSteamAudio, Log, TEXT("OnWorld_PostCreation: no SteamAudio scene for world %s"), *World->GetName());
}
}