LoadGameFeaturePlugin
LoadGameFeaturePlugin
#Overview
name: LoadGameFeaturePlugin
This variable is created as a Console Variable (cvar).
- type:
Cmd
- help:
Loads and activates a game feature plugin by PluginName or URL
It is referenced in 6
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of LoadGameFeaturePlugin is to load a Game Feature Plugin in Unreal Engine 5. Game Feature Plugins are a modular system that allows developers to add or modify game functionality dynamically.
This functionality is primarily used by the Game Features subsystem, which is part of the GameFeatures module in Unreal Engine 5. The GameFeaturesSubsystem class is responsible for managing the loading, activation, and deactivation of these plugins.
The value of this variable is not set directly, but rather it represents a function or command that can be called to load a Game Feature Plugin. It can be invoked through various methods:
- Directly calling the LoadGameFeaturePlugin function on the UGameFeaturesSubsystem instance.
- Using the console command “LoadGameFeaturePlugin” registered in the Initialize function of UGameFeaturesSubsystem.
This function interacts with other related functions like LoadAndActivateGameFeaturePlugin, which not only loads but also activates the plugin.
Developers should be aware of the following when using this functionality:
- The plugin URL or name must be correctly specified.
- The function supports loading single or multiple plugins.
- There are overloads that allow specifying additional protocol options and completion delegates.
- The system checks if the plugin is allowed to be loaded before proceeding.
Best practices when using this functionality include:
- Always handle the completion delegate to know when the loading process is finished and if it was successful.
- Use the appropriate overload based on your needs (e.g., single vs. multiple plugins, with or without protocol options).
- Ensure that the necessary game-specific policies are in place to control which plugins are allowed to be loaded.
- Consider using LoadAndActivateGameFeaturePlugin if you want to immediately activate the plugin after loading.
- Be mindful of performance implications when loading multiple plugins simultaneously.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/Runtime/GameFeatures/Source/GameFeatures/Private/GameFeaturesProjectPolicies.cpp:95
Scope (from outer to inner):
file
function void UGameFeaturesProjectPolicies::ExplicitLoadGameFeaturePlugin
Source code excerpt:
else
{
UGameFeaturesSubsystem::Get().LoadGameFeaturePlugin(PluginURL, CompleteDelegate);
}
}
#Loc: <Workspace>/Engine/Plugins/Runtime/GameFeatures/Source/GameFeatures/Private/GameFeaturesSubsystem.cpp:378
Scope (from outer to inner):
file
function void UGameFeaturesSubsystem::Initialize
Source code excerpt:
IConsoleManager::Get().RegisterConsoleCommand(
TEXT("LoadGameFeaturePlugin"),
TEXT("Loads and activates 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().LoadAndActivateGameFeaturePlugin(PluginURL.GetValue(), FGameFeaturePluginLoadComplete());
}
}),
ECVF_Cheat);
IConsoleManager::Get().RegisterConsoleCommand(
TEXT("DeactivateGameFeaturePlugin"),
TEXT("Deactivates 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))
#Loc: <Workspace>/Engine/Plugins/Runtime/GameFeatures/Source/GameFeatures/Private/GameFeaturesSubsystem.cpp:1155
Scope (from outer to inner):
file
function void UGameFeaturesSubsystem::LoadGameFeaturePlugin
Source code excerpt:
}
void UGameFeaturesSubsystem::LoadGameFeaturePlugin(const FString& PluginURL, const FGameFeaturePluginLoadComplete& CompleteDelegate)
{
LoadGameFeaturePlugin(PluginURL, FGameFeatureProtocolOptions(), CompleteDelegate);
}
void UGameFeaturesSubsystem::LoadGameFeaturePlugin(const FString& PluginURL, const FGameFeatureProtocolOptions& ProtocolOptions, const FGameFeaturePluginLoadComplete& CompleteDelegate)
{
const bool bIsPluginAllowed = GameSpecificPolicies->IsPluginAllowed(PluginURL);
if (!bIsPluginAllowed)
{
CompleteDelegate.ExecuteIfBound(UE::GameFeatures::FResult(MakeError(UE::GameFeatures::SubsystemErrorNamespace + UE::GameFeatures::CommonErrorCodes::PluginNotAllowed)));
return;
#Loc: <Workspace>/Engine/Plugins/Runtime/GameFeatures/Source/GameFeatures/Private/GameFeaturesSubsystem.cpp:1194
Scope (from outer to inner):
file
function void UGameFeaturesSubsystem::LoadGameFeaturePlugin
Source code excerpt:
}
void UGameFeaturesSubsystem::LoadGameFeaturePlugin(TConstArrayView<FString> PluginURLs, const FGameFeatureProtocolOptions& ProtocolOptions, const FMultipleGameFeaturePluginsLoaded& CompleteDelegate)
{
struct FLoadContext
{
TMap<FString, UE::GameFeatures::FResult> Results;
FMultipleGameFeaturePluginsLoaded CompleteDelegate;
#Loc: <Workspace>/Engine/Plugins/Runtime/GameFeatures/Source/GameFeatures/Private/GameFeaturesSubsystem.cpp:1245
Scope (from outer to inner):
file
function void UGameFeaturesSubsystem::LoadGameFeaturePlugin
Source code excerpt:
for (const FString& PluginURL : PluginURLs)
{
LoadGameFeaturePlugin(PluginURL, ProtocolOptions, FGameFeaturePluginChangeStateComplete::CreateLambda([LoadContext, PluginURL](const UE::GameFeatures::FResult& Result)
{
LoadContext->Results.Add(PluginURL, Result);
++LoadContext->NumPluginsLoaded;
UE_LOG(LogGameFeatures, VeryVerbose, TEXT("Finished Loading %i GFPs"), LoadContext->NumPluginsLoaded);
}));
}
#Loc: <Workspace>/Engine/Plugins/Runtime/GameFeatures/Source/GameFeatures/Public/GameFeaturesSubsystem.h:516
Scope (from outer to inner):
file
class class UGameFeaturesSubsystem : public UEngineSubsystem
Source code excerpt:
/** Loads a single game feature plugin. */
void LoadGameFeaturePlugin(const FString& PluginURL, const FGameFeaturePluginLoadComplete& CompleteDelegate);
void LoadGameFeaturePlugin(const FString& PluginURL, const FGameFeatureProtocolOptions& ProtocolOptions, const FGameFeaturePluginLoadComplete& CompleteDelegate);
void LoadGameFeaturePlugin(TConstArrayView<FString> PluginURLs, const FGameFeatureProtocolOptions& ProtocolOptions, const FMultipleGameFeaturePluginsLoaded& CompleteDelegate);
/** Loads a single game feature plugin and activates it. */
void LoadAndActivateGameFeaturePlugin(const FString& PluginURL, const FGameFeaturePluginLoadComplete& CompleteDelegate);
void LoadAndActivateGameFeaturePlugin(const FString& PluginURL, const FGameFeatureProtocolOptions& ProtocolOptions, const FGameFeaturePluginLoadComplete& CompleteDelegate);
void LoadAndActivateGameFeaturePlugin(TConstArrayView<FString> PluginURLs, const FGameFeatureProtocolOptions& ProtocolOptions, const FMultipleGameFeaturePluginsLoaded& CompleteDelegate);