LastExecutedPlayModeType

LastExecutedPlayModeType

#Overview

name: LastExecutedPlayModeType

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 14 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of LastExecutedPlayModeType is to store and track the last play mode type that was executed in the Unreal Engine editor. This variable is primarily used for managing and controlling the Play-in-Editor (PIE) functionality.

LastExecutedPlayModeType is mainly used by the Unreal Engine’s editor subsystem, specifically in the Play-in-Editor (PIE) functionality. It is also utilized by various plugins and modules such as MovieRenderPipeline, MovieSceneCaptureDialog, and RiderGameControl.

The value of this variable is set in several places throughout the codebase:

  1. In the UMoviePipelinePIEExecutor::Start function
  2. In the FInEditorCapture::OverridePlaySettings function
  3. In the SetLastExecutedPlayMode function

This variable interacts with other play settings variables, such as PlayInEditorSettings, and is often used in conjunction with other play mode-related settings.

Developers should be aware of the following when using this variable:

  1. It affects the behavior of the “Repeat Last Play” functionality in the editor.
  2. It is used to determine the icon and tooltip for the play buttons in the editor.
  3. It influences the behavior of various play-related commands and their ability to execute.

Best practices when using this variable include:

  1. Ensure that the variable is updated appropriately when changing play modes programmatically.
  2. Use the SetLastExecutedPlayMode function to update the variable, as it handles saving the configuration and notifying the editor of the change.
  3. Be aware of its impact on the user interface and editor functionality when modifying its value.
  4. Consider the implications on multi-client and dedicated server scenarios when working with this variable.

#Setting Variables

#References In INI files

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

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/MovieScene/MovieRenderPipeline/Source/MovieRenderPipelineEditor/Private/MoviePipelinePIEExecutor.cpp:150

Scope (from outer to inner):

file
function     void UMoviePipelinePIEExecutor::Start

Source code excerpt:

	PlayInEditorSettings->bLaunchSeparateServer = false;
	PlayInEditorSettings->SetRunUnderOneProcess(true);
	PlayInEditorSettings->LastExecutedPlayModeType = EPlayModeType::PlayMode_InEditorFloating;
	PlayInEditorSettings->bUseNonRealtimeAudioDevice = true;

	FRequestPlaySessionParams Params;
	Params.EditorPlaySettings = PlayInEditorSettings;
	Params.CustomPIEWindow = CustomWindow;
	Params.GlobalMapOverride = InJob->Map.GetAssetPathString();

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

Scope (from outer to inner):

file
function     void FInEditorCapture::OverridePlaySettings

Source code excerpt:

	PlayInEditorSettings->CenterNewWindow = false;
	PlayInEditorSettings->NewWindowPosition = FIntPoint::NoneValue; // It will center PIE to the middle of the screen the first time it is run (until the user drag the window somewhere else)
	PlayInEditorSettings->LastExecutedPlayModeType = EPlayModeType::PlayMode_InEditorFloating;

	// Reset everything else
	PlayInEditorSettings->GameGetsMouseControl = false;
	PlayInEditorSettings->ShowMouseControlLabel = false;
	PlayInEditorSettings->ViewportGetsHMDControl = false;
	PlayInEditorSettings->ShouldMinimizeEditorOnVRPIE = true;

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

Scope (from outer to inner):

file
class        class ULevelEditorPlaySettings : public UObject

Source code excerpt:

	/** The last type of play session the user ran. */
	UPROPERTY(config)
	TEnumAsByte<EPlayModeType> LastExecutedPlayModeType;

	/** The name of the last device that the user ran a play session on. */
	UPROPERTY(config)
	FString LastExecutedPIEPreviewDevice;
public:

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Kismet2/DebuggerCommands.cpp:770

Scope (from outer to inner):

file
function     void SetLastExecutedPlayMode

Source code excerpt:

{
	ULevelEditorPlaySettings* PlaySettings = GetMutableDefault<ULevelEditorPlaySettings>();
	PlaySettings->LastExecutedPlayModeType = PlayMode;

	FPropertyChangedEvent PropChangeEvent(ULevelEditorPlaySettings::StaticClass()->FindPropertyByName(GET_MEMBER_NAME_CHECKED(ULevelEditorPlaySettings, LastExecutedPlayModeType)));
	PlaySettings->PostEditChangeProperty(PropChangeEvent);

	PlaySettings->SaveConfig();
}

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Kismet2/DebuggerCommands.cpp:1238

Scope (from outer to inner):

file
function     const TSharedRef < FUICommandInfo > GetLastPlaySessionCommand

Source code excerpt:

	TSharedRef < FUICommandInfo > Command = Commands.PlayInViewport.ToSharedRef();

	switch (PlaySettings->LastExecutedPlayModeType)
	{
	case PlayMode_InViewPort:
		Command = Commands.PlayInViewport.ToSharedRef();
		break;

	case PlayMode_InEditorFloating:

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Kismet2/DebuggerCommands.cpp:1315

Scope (from outer to inner):

file
function     void RecordLastExecutedPlayMode

Source code excerpt:

		FString PlayModeString;

		switch (PlaySettings->LastExecutedPlayModeType)
		{
		case PlayMode_InViewPort:
			PlayModeString = TEXT("InViewPort");
			break;

		case PlayMode_InEditorFloating:

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Kismet2/DebuggerCommands.cpp:1381

Scope (from outer to inner):

file
function     void FInternalPlayWorldCommandCallbacks::RepeatLastPlay_Clicked

Source code excerpt:


	// hand over to Turnkey module
	if (PlaySettings->LastExecutedPlayModeType == EPlayModeType::PlayMode_QuickLaunch)
	{
#if UE_WITH_TURNKEY_SUPPORT
		ITurnkeySupportModule::Get().RepeatQuickLaunch(PlaySettings->LastExecutedLaunchName);
#endif
	}
	else

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Kismet2/DebuggerCommands.cpp:1406

Scope (from outer to inner):

file
function     bool FInternalPlayWorldCommandCallbacks::RepeatLastPlay_CanExecute

Source code excerpt:


	const ULevelEditorPlaySettings* PlaySettings = GetDefault<ULevelEditorPlaySettings>();
	if (PlaySettings->LastExecutedPlayModeType == EPlayModeType::PlayMode_QuickLaunch)
	{
		// return true, and let Turnkey module determine if it's still usable, and show an error if not
		return true;
	}

	return FPlayWorldCommands::GlobalPlayWorldActions->CanExecuteAction(GetLastPlaySessionCommand());

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Kismet2/DebuggerCommands.cpp:1419

Scope (from outer to inner):

file
function     FText FInternalPlayWorldCommandCallbacks::GetRepeatLastPlayToolTip

Source code excerpt:

{
	const ULevelEditorPlaySettings* PlaySettings = GetDefault<ULevelEditorPlaySettings>();
	if (PlaySettings->LastExecutedPlayModeType == EPlayModeType::PlayMode_QuickLaunch)
	{
		// @todo make a proper tooltip!
		return FText::FromString(PlaySettings->LastExecutedLaunchName);
	}

	return GetLastPlaySessionCommand()->GetDescription();

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Kismet2/DebuggerCommands.cpp:1433

Scope (from outer to inner):

file
function     FSlateIcon FInternalPlayWorldCommandCallbacks::GetRepeatLastPlayIcon

Source code excerpt:

	// get platform icon for Quick Launch mode
	const ULevelEditorPlaySettings* PlaySettings = GetDefault<ULevelEditorPlaySettings>();
	if (PlaySettings->LastExecutedPlayModeType == EPlayModeType::PlayMode_QuickLaunch)
	{
		FTargetDeviceId DeviceId;
		FTargetDeviceId::Parse(PlaySettings->LastExecutedLaunchName, DeviceId);

		// get platform name from DeviceId
		

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Kismet2/DebuggerCommands.cpp:1719

Scope (from outer to inner):

file
function     bool FInternalPlayWorldCommandCallbacks::PlayInModeIsChecked

Source code excerpt:

bool FInternalPlayWorldCommandCallbacks::PlayInModeIsChecked(EPlayModeType PlayMode)
{
	return (PlayMode == GetDefault<ULevelEditorPlaySettings>()->LastExecutedPlayModeType);
}


bool FInternalPlayWorldCommandCallbacks::PlayInLocation_CanExecute(EPlayModeLocations Location)
{
	if (IsStoppedAtBreakpoint_InEngineMode() || DebuggerCommands::IsVREditorActive())

#Loc: <Workspace>/Projects/Lyra/Plugins/Developer/RiderLink/Source/RiderGameControl/Private/RiderGameControl.cpp:117

Scope (from outer to inner):

file
function     static FPlaySettings RetrieveSettings

Source code excerpt:


    FPlaySettings settings;
    settings.PlayMode = PlayInSettings->LastExecutedPlayModeType;
    PlayInSettings->GetPlayNumberOfClients(settings.NumberOfClients);
#if ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION <= 24
    PlayInSettings->GetPlayNetDedicated(settings.bNetDedicated);
#else
    settings.bNetDedicated = PlayInSettings->bLaunchSeparateServer;
#endif

#Loc: <Workspace>/Projects/Lyra/Plugins/Developer/RiderLink/Source/RiderGameControl/Private/RiderGameControl.cpp:143

Scope (from outer to inner):

file
function     static void UpdateSettings

Source code excerpt:

            ? PlayLocation_DefaultPlayerStart
            : PlayLocation_CurrentCameraLocation;
    PlayInSettings->LastExecutedPlayModeType = settings.PlayMode;

    PlayInSettings->PostEditChange();
    PlayInSettings->SaveConfig();
}

#Loc: <Workspace>/Projects/Lyra/Plugins/Developer/RiderLink/Source/RiderGameControl/Private/RiderGameControl.cpp:397

Scope (from outer to inner):

file
function     FRiderGameControl::FRiderGameControl
lambda-function
lambda-function

Source code excerpt:

                             = GetDefault<ULevelEditorPlaySettings>();
                         check(PlayInSettings);
                         const EPlayModeType PlayMode = PlayInSettings->LastExecutedPlayModeType;

                         RequestPlayWorldCommand(Actions.PlayModeCommands[PlayMode], requestID);
                     }
             );
        Model.get_requestPauseFromRider()
             .advise(Lifetime, [this](int requestID)