TerminateGameFeaturePlugin
TerminateGameFeaturePlugin
#Overview
name: TerminateGameFeaturePlugin
This variable is created as a Console Variable (cvar).
- type:
Cmd
- help:
Terminates a game feature plugin by PluginName or URL
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of TerminateGameFeaturePlugin is to terminate a specific Game Feature Plugin and remove all associated plugin tracking data within the Unreal Engine 5 Game Features subsystem.
This setting variable is primarily used by the Game Features subsystem, which is part of the Runtime Game Features plugin in Unreal Engine 5. It’s specifically utilized within the UGameFeaturesSubsystem class.
The value of this variable is not set directly, as it’s not a traditional setting variable. Instead, it’s a function name that’s registered as a console command. The function is called when the console command “TerminateGameFeaturePlugin” is invoked, either programmatically or through the game console.
This function interacts with other parts of the Game Features subsystem, particularly:
- The GameFeaturePluginStateMachine, which manages the state of Game Feature plugins.
- The ChangeGameFeatureDestination function, which is used to change the state of a Game Feature plugin.
Developers must be aware of the following when using this function:
- It requires a valid PluginURL to identify the plugin to terminate.
- It can be called with or without a completion delegate.
- Terminating a plugin will remove all associated tracking data, which could impact other parts of the game that depend on that plugin.
Best practices when using this function include:
- Always ensure the PluginURL is valid and corresponds to an active Game Feature plugin.
- Use the version with the completion delegate to handle any post-termination logic or error handling.
- Be cautious when terminating plugins during gameplay, as it could lead to unexpected behavior if other systems depend on the terminated plugin.
- Consider using this in conjunction with the CancelGameFeatureStateChange function if you need to handle cancellation scenarios.
- Log or handle any errors that might occur during the termination process.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/Runtime/GameFeatures/Source/GameFeatures/Private/GameFeaturesSubsystem.cpp:450
Scope (from outer to inner):
file
function void UGameFeaturesSubsystem::Initialize
Source code excerpt:
IConsoleManager::Get().RegisterConsoleCommand(
TEXT("TerminateGameFeaturePlugin"),
TEXT("Terminates a game feature plugin by PluginName or URL"),
FConsoleCommandWithWorldArgsAndOutputDeviceDelegate::CreateLambda([](const TArray<FString>& Args, UWorld*, FOutputDevice& Ar)
{
if (TOptional<FString> PluginURL = UE::GameFeatures::GetPluginUrlForConsoleCommand(Args, Ar))
{
UGameFeaturesSubsystem::Get().TerminateGameFeaturePlugin(PluginURL.GetValue());
}
}),
ECVF_Cheat);
}
void UGameFeaturesSubsystem::Deinitialize()
{
UE_LOG(LogGameFeatures, Log, TEXT("Shutting down game features subsystem"));
if ((GameSpecificPolicies != nullptr) && bInitializedPolicyManager)
#Loc: <Workspace>/Engine/Plugins/Runtime/GameFeatures/Source/GameFeatures/Private/GameFeaturesSubsystem.cpp:1633
Scope (from outer to inner):
file
function void UGameFeaturesSubsystem::UninstallGameFeaturePlugin
lambda-function
Source code excerpt:
if (Result.HasValue())
{
TerminateGameFeaturePlugin(PluginURL, CompleteDelegate);
}
//If we failed just bubble error up
else
{
CompleteDelegate.ExecuteIfBound(Result);
}
#Loc: <Workspace>/Engine/Plugins/Runtime/GameFeatures/Source/GameFeatures/Private/GameFeaturesSubsystem.cpp:1643
Scope (from outer to inner):
file
function void UGameFeaturesSubsystem::TerminateGameFeaturePlugin
Source code excerpt:
}
void UGameFeaturesSubsystem::TerminateGameFeaturePlugin(const FString& PluginURL)
{
TerminateGameFeaturePlugin(PluginURL, FGameFeaturePluginTerminateComplete());
}
void UGameFeaturesSubsystem::TerminateGameFeaturePlugin(const FString& PluginURL, const FGameFeaturePluginTerminateComplete& CompleteDelegate)
{
if (UGameFeaturePluginStateMachine* StateMachine = FindGameFeaturePluginStateMachine(PluginURL))
{
ChangeGameFeatureDestination(StateMachine, FGameFeaturePluginStateRange(EGameFeaturePluginState::Terminal), CompleteDelegate);
}
else
#Loc: <Workspace>/Engine/Plugins/Runtime/GameFeatures/Source/GameFeatures/Public/GameFeaturesSubsystem.h:560
Scope (from outer to inner):
file
class class UGameFeaturesSubsystem : public UEngineSubsystem
Source code excerpt:
/** Terminate the GameFeaturePlugin and remove all associated plugin tracking data. */
void TerminateGameFeaturePlugin(const FString& PluginURL);
void TerminateGameFeaturePlugin(const FString& PluginURL, const FGameFeaturePluginTerminateComplete& CompleteDelegate);
/** Attempt to cancel any state change. Calls back when cancelation is complete. Any other pending callbacks will be called with a canceled error. */
void CancelGameFeatureStateChange(const FString& PluginURL);
void CancelGameFeatureStateChange(const FString& PluginURL, const FGameFeaturePluginChangeStateComplete& CompleteDelegate);
void CancelGameFeatureStateChange(TConstArrayView<FString> PluginURLs, const FMultipleGameFeaturePluginChangeStateComplete& CompleteDelegate);