LastExecutedPlayModeLocation

LastExecutedPlayModeLocation

#Overview

name: LastExecutedPlayModeLocation

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

#Summary

#Usage in the C++ source code

The purpose of LastExecutedPlayModeLocation is to store the last type of play location the user selected when running a play session in the Unreal Engine editor. This setting is part of the editor’s play mode configuration system.

This variable is primarily used by the Unreal Engine’s editor subsystem, specifically within the UnrealEd module. It’s utilized in the LevelEditorPlaySettings class and various play mode-related functions.

The value of this variable is set in multiple places:

  1. In the FInternalPlayWorldCommandCallbacks::PlayInLocation_Clicked function, where it’s updated based on the user’s selection.
  2. In the UpdateSettings function within the RiderGameControl plugin, where it’s set based on external play settings.

LastExecutedPlayModeLocation interacts with other variables and systems:

  1. It’s used in conjunction with LastExecutedPlayModeType to determine the last play session configuration.
  2. It’s checked against the availability of a player start position in the level.

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

  1. The value can be either PlayLocation_CurrentCameraLocation or PlayLocation_DefaultPlayerStart.
  2. If there’s no player start in the level, it will default to PlayLocation_CurrentCameraLocation.
  3. This setting affects where the player will spawn when starting a play session in the editor.

Best practices when using this variable include:

  1. Ensure that the level has a player start if you want to use PlayLocation_DefaultPlayerStart.
  2. Consider the implications of changing this setting on gameplay testing and level design.
  3. Use the provided FInternalPlayWorldCommandCallbacks functions to interact with this setting rather than modifying it directly.
  4. Remember that this setting is saved to config, so changes will persist between editor sessions.

#Setting Variables

#References In INI files

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

#References in C++ code

#Callsites

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

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

Scope (from outer to inner):

file
class        class ULevelEditorPlaySettings : public UObject

Source code excerpt:

	/** The last type of play location the user ran. */
	UPROPERTY(config)
	TEnumAsByte<EPlayModeLocations> LastExecutedPlayModeLocation;

	/** 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. */

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

Scope (from outer to inner):

file
function     void RecordLastExecutedPlayMode

Source code excerpt:

		FString PlayLocationString;

		switch (PlaySettings->LastExecutedPlayModeLocation)
		{
		case PlayLocation_CurrentCameraLocation:
			PlayLocationString = TEXT("CurrentCameraLocation");
			break;

		case PlayLocation_DefaultPlayerStart:

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

Scope (from outer to inner):

file
function     void FInternalPlayWorldCommandCallbacks::PlayInLocation_Clicked

Source code excerpt:

{
	ULevelEditorPlaySettings* PlaySettings = GetMutableDefault<ULevelEditorPlaySettings>();
	PlaySettings->LastExecutedPlayModeLocation = Location;
	PlaySettings->PostEditChange();
	PlaySettings->SaveConfig();
}


bool FInternalPlayWorldCommandCallbacks::PlayInLocation_IsChecked(EPlayModeLocations Location)

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

Scope (from outer to inner):

file
function     bool FInternalPlayWorldCommandCallbacks::PlayInLocation_IsChecked

Source code excerpt:

	{
	case PlayLocation_CurrentCameraLocation:
		return ((GetDefault<ULevelEditorPlaySettings>()->LastExecutedPlayModeLocation == PlayLocation_CurrentCameraLocation) || (GEditor->CheckForPlayerStart() == nullptr));

	case PlayLocation_DefaultPlayerStart:
		return ((GetDefault<ULevelEditorPlaySettings>()->LastExecutedPlayModeLocation == PlayLocation_DefaultPlayerStart) && (GEditor->CheckForPlayerStart() != nullptr));
	}

	return false;
}

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

Scope (from outer to inner):

file
function     EPlayModeLocations FInternalPlayWorldCommandCallbacks::GetPlayModeLocation

Source code excerpt:

	// We can't use PlayLocation_DefaultPlayerStart without a player start position
	return GEditor->CheckForPlayerStart()
		? static_cast<EPlayModeLocations>(GetDefault<ULevelEditorPlaySettings>()->LastExecutedPlayModeLocation)
		: PlayLocation_CurrentCameraLocation;
}

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

Scope (from outer to inner):

file
function     static FPlaySettings RetrieveSettings

Source code excerpt:

    settings.bNetDedicated = PlayInSettings->bLaunchSeparateServer;
#endif
    settings.bSpawnAtPlayerStart = PlayInSettings->LastExecutedPlayModeLocation == PlayLocation_DefaultPlayerStart;

    return settings;
}

static void UpdateSettings(ULevelEditorPlaySettings* PlayInSettings, const FPlaySettings& settings)
{

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

Scope (from outer to inner):

file
function     static void UpdateSettings

Source code excerpt:

    PlayInSettings->bLaunchSeparateServer = settings.bNetDedicated;
#endif
    PlayInSettings->LastExecutedPlayModeLocation =
        settings.bSpawnAtPlayerStart
            ? PlayLocation_DefaultPlayerStart
            : PlayLocation_CurrentCameraLocation;
    PlayInSettings->LastExecutedPlayModeType = settings.PlayMode;

    PlayInSettings->PostEditChange();