EnableGameSound

EnableGameSound

#Overview

name: EnableGameSound

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of EnableGameSound is to control whether sounds are played during Play In Editor (PIE) sessions in Unreal Engine 5. This setting variable is primarily used in the editor’s play-testing functionality.

The Unreal Engine subsystems that rely on this setting variable are primarily the Editor subsystem and the Audio subsystem. It is used in the Movie Scene Capture module and the UnrealEd module.

The value of this variable is set in the LevelEditorPlaySettings class, which is a UObject that stores various settings for Play In Editor functionality. It is defined as a UPROPERTY with the ‘config’ and ‘EditAnywhere’ specifiers, meaning it can be edited in the project settings and saved to configuration files.

This variable interacts with other PIE-related settings, such as SoloAudioInFirstPIEClient and PlayInEditorSoundQualityLevel. It also affects the behavior of the audio device during PIE sessions.

Developers must be aware that:

  1. This setting affects all PIE sessions, including single-player and multiplayer tests.
  2. Disabling game sound can be useful for performance testing or when working in environments where audio output is not desired.
  3. The setting can be overridden programmatically for specific use cases, such as during movie scene captures.

Best practices when using this variable include:

  1. Ensure it is enabled when testing audio-related features or when audio is crucial for the gameplay experience.
  2. Consider disabling it temporarily when focusing on visual or performance aspects of the game to reduce system load.
  3. Be aware of its state when debugging audio-related issues in PIE sessions.
  4. Use it in conjunction with other audio-related settings for fine-tuned control over the PIE audio experience.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEditorPerProjectUserSettings.ini:223, section: [/Script/UnrealEd.LevelEditorPlaySettings]

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Editor/MovieSceneCaptureDialog/Private/MovieSceneCaptureDialogModule.cpp:489

Scope (from outer to inner):

file
function     void FInEditorCapture::OverridePlaySettings

Source code excerpt:

	PlayInEditorSettings->ViewportGetsHMDControl = false;
	PlayInEditorSettings->ShouldMinimizeEditorOnVRPIE = true;
	PlayInEditorSettings->EnableGameSound = CaptureObject->AudioCaptureProtocolType != UNullAudioCaptureProtocol::StaticClass();
	PlayInEditorSettings->bOnlyLoadVisibleLevelsInPIE = false;
	PlayInEditorSettings->bPreferToStreamLevelsInPIE = false;
	PlayInEditorSettings->PIEAlwaysOnTop = false;
	PlayInEditorSettings->DisableStandaloneSound = false;
	PlayInEditorSettings->AdditionalLaunchParameters = TEXT("");
	PlayInEditorSettings->BuildGameBeforeLaunch = EPlayOnBuildMode::PlayOnBuild_Never;

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Classes/Settings/LevelEditorPlaySettings.h:261

Scope (from outer to inner):

file
class        class ULevelEditorPlaySettings : public UObject

Source code excerpt:

	/** Whether to play sounds during PIE */
	UPROPERTY(config, EditAnywhere, Category=PlayInEditor, meta=(ToolTip="Whether to play sounds when in a Play In Editor session"))
	bool EnableGameSound;

	/** Whether to automatically solo audio in first PIE client. */
	UPROPERTY(config, EditAnywhere, Category = PlayInEditor, meta = (ToolTip="Whether to automatically solo audio in first PIE client", EditCondition="EnableGameSound", DisplayName = "Solo Audio in First PIE Client"))
	bool SoloAudioInFirstPIEClient;

	/** Whether to play a sound when entering and exiting PIE */

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/PlayLevel.cpp:2487

Scope (from outer to inner):

file
function     void UEditorEngine::ResetPIEAudioSetting

Source code excerpt:

{
	ULevelEditorPlaySettings* PlayInSettings = GetMutableDefault<ULevelEditorPlaySettings>();
	if (!PlayInSettings->EnableGameSound)
	{
		if (FAudioDevice* AudioDevice = CurrentPieWorld->GetAudioDeviceRaw())
		{
			AudioDevice->SetTransientPrimaryVolume(0.0f);
		}
	}

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/PlayLevel.cpp:2991

Scope (from outer to inner):

file
function     UGameInstance* UEditorEngine::CreateInnerProcessPIEGameInstance

Source code excerpt:

		ViewportClient->EngineShowFlags.SetServerDrawDebug(PlayInSettings->ShowServerDebugDrawingByDefault());

		if (!InParams.EditorPlaySettings->EnableGameSound)
		{
			if (FAudioDeviceHandle GameInstanceAudioDevice = GameInstance->GetWorld()->GetAudioDevice())
			{
				GameInstanceAudioDevice->SetTransientPrimaryVolume(0.0f);
			}
		}

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Settings/LevelEditorPlaySettingsCustomization.cpp:309

Scope (from outer to inner):

file
function     void FLevelEditorPlaySettingsCustomization::CustomizeDetails

Source code excerpt:

		PlayInEditorCategory.GetDefaultProperties( PIECategoryProperties, true, false );

		TSharedPtr<IPropertyHandle> PIEEnableSoundHandle = LayoutBuilder.GetProperty( GET_MEMBER_NAME_CHECKED( ULevelEditorPlaySettings, EnableGameSound ) );
		PIESoundQualityLevelHandle = LayoutBuilder.GetProperty( GET_MEMBER_NAME_CHECKED( ULevelEditorPlaySettings, PlayInEditorSoundQualityLevel ) );
		PIESoundQualityLevelHandle->MarkHiddenByCustomization();

		for ( TSharedRef<IPropertyHandle>& PropertyHandle : PIECategoryProperties )
		{
			if ( PropertyHandle->GetProperty() != PIESoundQualityLevelHandle->GetProperty() )