├── .gitignore ├── Binaries └── Win64 │ ├── UnrealEditor-MetaCheatManager.dll │ ├── UnrealEditor-MetaCheatManager.pdb │ └── UnrealEditor.modules ├── LICENSE ├── MetaCheatManager.uplugin ├── README.md ├── Resources └── Icon128.png └── Source └── MetaCheatManager ├── MetaCheatManager.Build.cs ├── Private ├── MetaCheatCommand.cpp ├── MetaCheatManager.cpp ├── MetaCheatManagerExtension.cpp ├── MetaCheatManagerModule.cpp └── MetaCheatManagerUtils.cpp └── Public ├── MetaCheatCommand.h ├── MetaCheatManager.h ├── MetaCheatManagerExtension.h ├── MetaCheatManagerInterface.h ├── MetaCheatManagerModule.h └── MetaCheatManagerUtils.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Visual Studio 2015 user specific files 2 | .vs/ 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | 22 | # Compiled Static libraries 23 | *.lai 24 | *.la 25 | *.a 26 | *.lib 27 | 28 | # Executables 29 | *.exe 30 | *.out 31 | *.app 32 | *.ipa 33 | 34 | # These project files can be generated by the engine 35 | *.xcodeproj 36 | *.xcworkspace 37 | *.sln 38 | *.suo 39 | *.opensdf 40 | *.sdf 41 | *.VC.db 42 | *.VC.opendb 43 | 44 | # Precompiled Assets 45 | SourceArt/**/*.png 46 | SourceArt/**/*.tga 47 | 48 | # Binary Files 49 | Binaries/* 50 | Plugins/*/Binaries/* 51 | 52 | # Builds 53 | Build/* 54 | 55 | # Whitelist PakBlacklist-.txt files 56 | !Build/*/ 57 | Build/*/** 58 | !Build/*/PakBlacklist*.txt 59 | 60 | # Don't ignore icon files in Build 61 | !Build/**/*.ico 62 | 63 | # Built data for maps 64 | *_BuiltData.uasset 65 | 66 | # Configuration files generated by the Editor 67 | Saved/* 68 | 69 | # Compiled source files for the engine to use 70 | Intermediate/* 71 | Plugins/*/Intermediate/* 72 | 73 | # Cache files for the editor to use 74 | DerivedDataCache/* 75 | -------------------------------------------------------------------------------- /Binaries/Win64/UnrealEditor-MetaCheatManager.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JanSeliv/MetaCheatManager/d3e92dbdd76283bbb66fb0d41ac5dbb76806cbf1/Binaries/Win64/UnrealEditor-MetaCheatManager.dll -------------------------------------------------------------------------------- /Binaries/Win64/UnrealEditor-MetaCheatManager.pdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JanSeliv/MetaCheatManager/d3e92dbdd76283bbb66fb0d41ac5dbb76806cbf1/Binaries/Win64/UnrealEditor-MetaCheatManager.pdb -------------------------------------------------------------------------------- /Binaries/Win64/UnrealEditor.modules: -------------------------------------------------------------------------------- 1 | { 2 | "BuildId": "33043543", 3 | "Modules": 4 | { 5 | "MetaCheatManager": "UnrealEditor-MetaCheatManager.dll" 6 | } 7 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Yevhenii Selivanov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /MetaCheatManager.uplugin: -------------------------------------------------------------------------------- 1 | { 2 | "FileVersion": 3, 3 | "Version": 1, 4 | "VersionName": "1.0", 5 | "FriendlyName": "Meta Cheat Manager", 6 | "Description": "Plugin allows to call any cheat function in 'Your.Cheat.Name' format from the console command.", 7 | "Category": "Programming", 8 | "CreatedBy": "Yevhenii Selivanov", 9 | "CreatedByURL": "https://github.com/JanSeliv/MetaCheatManager", 10 | "DocsURL": "", 11 | "MarketplaceURL": "", 12 | "SupportURL": "mailto:janseliw@gmail.com", 13 | "EngineVersion": "5.4.0", 14 | "EnabledByDefault": true, 15 | "CanContainContent": false, 16 | "IsBetaVersion": false, 17 | "Installed": false, 18 | "Modules": [ 19 | { 20 | "Name": "MetaCheatManager", 21 | "Type": "Runtime", 22 | "LoadingPhase": "Default" 23 | } 24 | ] 25 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![License](https://img.shields.io/badge/license-MIT-brightgreen.svg) 2 | ![Unreal Engine](https://img.shields.io/badge/Unreal-5.4-dea309?style=flat&logo=unrealengine) 3 | 4 |
5 |

6 | 7 | Logo 8 | 9 |

>_ Meta Cheat Manager

10 |

11 | Run cheats with 'Category.Command' console format 12 |
13 |
14 | Join our Discord ›› 15 |
16 | Releases 17 | · 18 | Docs 19 |

20 | 21 | ## 🌟 About 22 | 23 | The Meta Cheat Manager plugin introduces a feature to Unreal Engine 5 that allows you to call cheat functions with custom meta names from the console command in the 'Your.Cheat.Name' format. 24 | 25 | This functionality helps replace the '_meta=(OverrideNativeName="Your.Cheat.Name"))_' feature, which was available in Unreal Engine 4 but became unavailable in Unreal Engine 5 due to the removal of Blueprint Nativization. 26 | 27 | ![MetaCheatManager](https://github.com/user-attachments/assets/065f9fa7-a452-44bb-809d-99be7328eaf5) 28 | 29 | ## 🎓 Sample Projects 30 | 31 | Visit our [Release](https://github.com/JanSeliv/MetaCheatManager/releases) page showcasing the Meta Cheat Manager. 32 | 33 | Also, explore this [game project repository](https://github.com/JanSeliv/Bomber) to see the Meta Cheat Manager in action. 34 | 35 | ## 📅 Changelog 36 | #### 2024-12-26 37 | - Updated to **Unreal Engine 5.4**. 38 | #### 2024-01-14 39 | - Updated to **Unreal Engine 5.3**. 40 | - Added 'Cheat Manager Extensions' support, useful for plugins and Game Feature modules populating their own cheats. 41 | #### 2023-05-31 42 | - 🎉 Initial public release on Unreal Engine 5.2 43 | 44 | ## 📫 Feedback & Contribution 45 | 46 | Feedback and contributions from the community are highly appreciated! 47 | 48 | If you'd like to contribute, please fork the project and create a pull request targeting the `develop` branch. 49 | 50 | If you've found a bug or have an idea for a new feature, please open a new issue on GitHub or join our [Discord](https://discord.gg/jbWgwDefnE). Thank you! 51 | 52 | ## 📜 License 53 | 54 | This project is licensed under the terms of the MIT license. See [LICENSE](LICENSE) for more details. 55 | 56 | We hope you find this plugin useful and we look forward to your feedback and contributions. 57 | -------------------------------------------------------------------------------- /Resources/Icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JanSeliv/MetaCheatManager/d3e92dbdd76283bbb66fb0d41ac5dbb76806cbf1/Resources/Icon128.png -------------------------------------------------------------------------------- /Source/MetaCheatManager/MetaCheatManager.Build.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Yevhenii Selivanov. 2 | 3 | using UnrealBuildTool; 4 | 5 | public class MetaCheatManager : ModuleRules 6 | { 7 | public MetaCheatManager(ReadOnlyTargetRules Target) : base(Target) 8 | { 9 | PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; 10 | CppStandard = CppStandardVersion.Latest; 11 | bEnableNonInlinedGenCppWarnings = true; 12 | 13 | PublicDependencyModuleNames.AddRange(new[] 14 | { 15 | "Core" 16 | } 17 | ); 18 | 19 | PrivateDependencyModuleNames.AddRange(new[] 20 | { 21 | "CoreUObject", "Engine", "Slate", "SlateCore" // Core 22 | , "EngineSettings" // UConsoleSettings 23 | } 24 | ); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Source/MetaCheatManager/Private/MetaCheatCommand.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Yevhenii Selivanov 2 | 3 | #include "MetaCheatCommand.h" 4 | //--- 5 | #include "ConsoleSettings.h" 6 | //--- 7 | #include UE_INLINE_GENERATED_CPP_BY_NAME(MetaCheatCommand) 8 | 9 | // Contains empty cheat command 10 | const FMetaCheatCommand FMetaCheatCommand::EmptyCommand = FMetaCheatCommand(); 11 | 12 | // Returns the Auto Complete Command from this structure object 13 | FAutoCompleteCommand FMetaCheatCommand::ToAutoCompleteCommand() const 14 | { 15 | FAutoCompleteCommand AutoCompleteCommand; 16 | AutoCompleteCommand.Command = CheatName.ToString(); 17 | AutoCompleteCommand.Desc = CheatDescription.ToString(); 18 | static FColor AutoCompleteCommandColor = GetDefault()->AutoCompleteCommandColor; 19 | AutoCompleteCommand.Color = AutoCompleteCommandColor; 20 | return AutoCompleteCommand; 21 | } 22 | 23 | #if WITH_EDITOR 24 | // Builds all the data for this command by function ptr 25 | FMetaCheatCommand FMetaCheatCommand::Create(const UFunction* InFunction) 26 | { 27 | if (!InFunction) 28 | { 29 | return EmptyCommand; 30 | } 31 | 32 | FMetaCheatCommand CheatCommand; 33 | CheatCommand.CheatName = FindCheatMetaData(InFunction); 34 | if (CheatCommand.CheatName.IsNone()) 35 | { 36 | // No cheat name, so this is not a cheat command 37 | return EmptyCommand; 38 | } 39 | 40 | CheatCommand.FunctionName = InFunction->GetFName(); 41 | CheatCommand.CheatDescription = FindCheatDescription(InFunction); 42 | return CheatCommand; 43 | } 44 | 45 | // Finds a value of the 'CheatName' meta data for the specified function, none if CheatName is not set 46 | FName FMetaCheatCommand::FindCheatMetaData(const UFunction* InFunction) 47 | { 48 | static const FName CheatNameMetaKey = TEXT("CheatName"); 49 | checkf(InFunction, TEXT("%s: 'InFunction' is null"), *FString(__FUNCTION__)); 50 | const FString* FoundMetaData = InFunction->FindMetaData(CheatNameMetaKey); 51 | return FoundMetaData ? FName(*FoundMetaData) : NAME_None; 52 | } 53 | 54 | // Finds the description for the specified function 55 | FName FMetaCheatCommand::FindCheatDescription(const UFunction* InFunction) 56 | { 57 | checkf(InFunction, TEXT("%s: 'InFunction' is null"), *FString(__FUNCTION__)); 58 | 59 | FString Description = TEXT(""); 60 | 61 | // Start with description of function param: Name[Type]. E.x: NewLevel[int32] 62 | for (TFieldIterator PropIt(InFunction); PropIt && PropIt->PropertyFlags & CPF_Parm; ++PropIt) 63 | { 64 | if (const FProperty* Prop = *PropIt) 65 | { 66 | Description += FString::Printf(TEXT("%s[%s] "), *Prop->GetName(), *Prop->GetCPPType()); 67 | } 68 | } 69 | 70 | // Get the first line of the function tooltip 71 | static const FString Delimiter = TEXT("\n"); 72 | FString FunctionToolTip = InFunction->GetToolTipText().ToString(); 73 | TArray SeparatedStrings; 74 | FunctionToolTip.ParseIntoArray(SeparatedStrings, *Delimiter); 75 | if (!FunctionToolTip.IsEmpty()) 76 | { 77 | FunctionToolTip = SeparatedStrings[0]; 78 | } 79 | 80 | // Add function tooltip to the total description 81 | Description.Append(FunctionToolTip); 82 | return FName(*Description); 83 | } 84 | #endif // WITH_EDITOR 85 | -------------------------------------------------------------------------------- /Source/MetaCheatManager/Private/MetaCheatManager.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Yevhenii Selivanov 2 | 3 | #include "MetaCheatManager.h" 4 | //--- 5 | #include "MetaCheatManagerUtils.h" 6 | //--- 7 | #include "Engine/Console.h" 8 | //--- 9 | #include UE_INLINE_GENERATED_CPP_BY_NAME(MetaCheatManager) 10 | 11 | // Is overridden to initialize all cheat commands on editor startup 12 | void UMetaCheatManager::PostInitProperties() 13 | { 14 | Super::PostInitProperties(); 15 | 16 | UMetaCheatManagerUtils::InitAllCheatCommands(this, /*Out*/AllCheatCommands); 17 | 18 | if (!UConsole::RegisterConsoleAutoCompleteEntries.IsBoundToObject(this)) 19 | { 20 | UConsole::RegisterConsoleAutoCompleteEntries.AddUObject(this, &ThisClass::RegisterAutoCompleteEntries); 21 | } 22 | } 23 | 24 | // Is overridden to convert meta CheatName Your.Cheat.Name to the function name YourCheatFunction whenever user enters the command 25 | bool UMetaCheatManager::ProcessConsoleExec(const TCHAR* Cmd, FOutputDevice& Ar, UObject* Executor) 26 | { 27 | const bool bProcessed = UMetaCheatManagerUtils::TryProcessConsoleExec(this, Cmd, Ar, Executor); 28 | return bProcessed || Super::ProcessConsoleExec(Cmd, Ar, Executor); 29 | } 30 | 31 | // Garbage things before destroying the Cheat Manager 32 | void UMetaCheatManager::BeginDestroy() 33 | { 34 | UConsole::RegisterConsoleAutoCompleteEntries.RemoveAll(this); 35 | 36 | Super::BeginDestroy(); 37 | } 38 | 39 | // Is bound to return all initialized meta cheat commands to see them in the console 40 | void UMetaCheatManager::RegisterAutoCompleteEntries(TArray& OutCommands) const 41 | { 42 | UMetaCheatManagerUtils::RegisterAutoCompleteEntries(/*out*/OutCommands, AllCheatCommands); 43 | } 44 | -------------------------------------------------------------------------------- /Source/MetaCheatManager/Private/MetaCheatManagerExtension.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Yevhenii Selivanov 2 | 3 | #include "MetaCheatManagerExtension.h" 4 | //--- 5 | #include "MetaCheatManagerUtils.h" 6 | //--- 7 | #include "Engine/Console.h" 8 | //--- 9 | #include UE_INLINE_GENERATED_CPP_BY_NAME(MetaCheatManagerExtension) 10 | 11 | // Is overridden to initialize all cheat commands on startup 12 | void UMetaCheatManagerExtension::PostInitProperties() 13 | { 14 | Super::PostInitProperties(); 15 | 16 | UMetaCheatManagerUtils::InitAllCheatCommands(this, /*Out*/AllCheatCommands); 17 | 18 | if (!UConsole::RegisterConsoleAutoCompleteEntries.IsBoundToObject(this)) 19 | { 20 | UConsole::RegisterConsoleAutoCompleteEntries.AddUObject(this, &ThisClass::RegisterAutoCompleteEntries); 21 | } 22 | } 23 | 24 | // Is overridden to convert meta CheatName Your.Cheat.Name to the function name YourCheatFunction whenever user enters the command 25 | bool UMetaCheatManagerExtension::ProcessConsoleExec(const TCHAR* Cmd, FOutputDevice& Ar, UObject* Executor) 26 | { 27 | const bool bProcessed = UMetaCheatManagerUtils::TryProcessConsoleExec(this, Cmd, Ar, Executor); 28 | return bProcessed || Super::ProcessConsoleExec(Cmd, Ar, Executor); 29 | } 30 | 31 | // Garbage things before destroying the Cheat Manager 32 | void UMetaCheatManagerExtension::BeginDestroy() 33 | { 34 | UConsole::RegisterConsoleAutoCompleteEntries.RemoveAll(this); 35 | 36 | Super::BeginDestroy(); 37 | } 38 | 39 | // Is bound to return all initialized meta cheat commands to see them in the console 40 | void UMetaCheatManagerExtension::RegisterAutoCompleteEntries(TArray& OutCommands) const 41 | { 42 | UMetaCheatManagerUtils::RegisterAutoCompleteEntries(/*out*/OutCommands, AllCheatCommands); 43 | } 44 | -------------------------------------------------------------------------------- /Source/MetaCheatManager/Private/MetaCheatManagerModule.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Yevhenii Selivanov. 2 | 3 | #include "MetaCheatManagerModule.h" 4 | //--- 5 | #include "Modules/ModuleManager.h" 6 | 7 | // Called right after the module DLL has been loaded and the module object has been created 8 | void FMetaCheatManagerModule::StartupModule() 9 | { 10 | // This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module 11 | } 12 | 13 | // Called before the module is unloaded, right before the module object is destroyed 14 | void FMetaCheatManagerModule::ShutdownModule() 15 | { 16 | // This function may be called during shutdown to clean up your module. For modules that support dynamic reloading, 17 | // we call this function before unloading the module. 18 | } 19 | 20 | IMPLEMENT_MODULE(FMetaCheatManagerModule, MetaCheatManager) 21 | -------------------------------------------------------------------------------- /Source/MetaCheatManager/Private/MetaCheatManagerUtils.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Yevhenii Selivanov 2 | 3 | #include "MetaCheatManagerUtils.h" 4 | //--- 5 | #include "MetaCheatCommand.h" 6 | #include "MetaCheatManagerInterface.h" 7 | //--- 8 | #include "ConsoleSettings.h" 9 | //--- 10 | #include UE_INLINE_GENERATED_CPP_BY_NAME(MetaCheatManagerUtils) 11 | 12 | void UMetaCheatManagerUtils::InitAllCheatCommands(const TScriptInterface CheatManager, TArray& OutAllCheatCommands) 13 | { 14 | #if WITH_EDITOR 15 | if (!ensureMsgf(CheatManager, TEXT("ASSERT: [%i] %s:\n'CheatManager' is not valid!"), __LINE__, *FString(__FUNCTION__))) 16 | { 17 | return; 18 | } 19 | 20 | UObject* CheatManagerObj = CheatManager.GetObject(); 21 | checkf(CheatManagerObj, TEXT("ERROR: [%i] %s:\n'CheatManagerObj' is null!"), __LINE__, *FString(__FUNCTION__)); 22 | 23 | // It automatically adds DefaultMetaCheatManager.ini config on the editor startup to the Config folder on your project 24 | // to have your cheat commands with custom Cheat Names in the packaged build as well, you don't need to do anything specific about it. 25 | // Such solution is used because any metadata can be obtained only in the Editor, so we store it in the config file for the build. 26 | 27 | if (!CheatManagerObj->HasAllFlags(RF_ClassDefaultObject)) 28 | { 29 | // Do not init cheat commands for instances since we save them as default values into config file 30 | return; 31 | } 32 | 33 | if (!OutAllCheatCommands.IsEmpty()) 34 | { 35 | OutAllCheatCommands.Empty(); 36 | } 37 | 38 | // Find all cheat commands 39 | for (TFieldIterator FunctionIt(CheatManagerObj->GetClass(), EFieldIteratorFlags::ExcludeSuper); FunctionIt; ++FunctionIt) 40 | { 41 | FMetaCheatCommand CheatCommand = FMetaCheatCommand::Create(*FunctionIt); 42 | if (CheatCommand.IsValid()) 43 | { 44 | OutAllCheatCommands.Emplace(MoveTemp(CheatCommand)); 45 | } 46 | } 47 | 48 | CheatManagerObj->TryUpdateDefaultConfigFile(); 49 | #endif // WITH_EDITOR 50 | } 51 | 52 | // Returns the cheat command associated with specified CheatName meta value 53 | const FMetaCheatCommand& UMetaCheatManagerUtils::GetCheatCommandByCheatName(FName CheatName, const TArray& InAllCheatCommands) 54 | { 55 | for (const FMetaCheatCommand& CheatCommandIt : InAllCheatCommands) 56 | { 57 | if (CheatCommandIt.CheatName.IsEqual(CheatName)) 58 | { 59 | return CheatCommandIt; 60 | } 61 | } 62 | 63 | return FMetaCheatCommand::EmptyCommand; 64 | } 65 | 66 | // Registers auto-complete entries for the cheat commands 67 | void UMetaCheatManagerUtils::RegisterAutoCompleteEntries(TArray& OutCommands, const TArray& InAllCheatCommands) 68 | { 69 | for (const FMetaCheatCommand& CheatCommandIt : InAllCheatCommands) 70 | { 71 | const FAutoCompleteCommand& NewCommand = CheatCommandIt.ToAutoCompleteCommand(); 72 | const bool bIsNew = !OutCommands.ContainsByPredicate([&NewCommand](const FAutoCompleteCommand& CommandIt) { return CommandIt.Command == NewCommand.Command; }); 73 | if (bIsNew) 74 | { 75 | OutCommands.Emplace(NewCommand); 76 | } 77 | } 78 | } 79 | 80 | // Processes the console execution of meta cheat commands 81 | bool UMetaCheatManagerUtils::TryProcessConsoleExec(const TScriptInterface& CheatManager, const TCHAR* const Cmd, FOutputDevice& Ar, UObject* Executor) 82 | { 83 | if (!ensureMsgf(CheatManager, TEXT("ASSERT: [%i] %s:\n'CheatManager' is not valid!"), __LINE__, *FString(__FUNCTION__))) 84 | { 85 | return false; 86 | } 87 | 88 | UObject* CheatManagerObj = CheatManager.GetObject(); 89 | checkf(CheatManagerObj, TEXT("ERROR: [%i] %s:\n'CheatManagerObj' is null!"), __LINE__, *FString(__FUNCTION__)); 90 | 91 | constexpr bool bUseEscape = true; 92 | const TCHAR* ParsedCmd = Cmd; 93 | FString CommandName = TEXT(""); 94 | if (!FParse::Token(/*InOut*/ParsedCmd, /*Out*/CommandName, bUseEscape)) 95 | { 96 | return false; 97 | } 98 | 99 | // CommandName: is the CheatName (Your.Cheat.Name) 100 | // Cmd: is the value (if any) that was passed to the cheat 101 | const FMetaCheatCommand& CheatCommand = GetCheatCommandByCheatName(*CommandName, CheatManager->GetAllCheatCommands()); 102 | if (!CheatCommand.IsValid()) 103 | { 104 | return false; 105 | } 106 | 107 | // Get the function name (YourCheatFunction) from the CheatName (Your.Cheat.Name) 108 | // and append it with the value that was passed to the cheat to process the call 109 | // YourFunctionCheat Value 110 | constexpr bool bForceCallWithNonExec = true; 111 | const FString CmdString = CheatCommand.FunctionName.ToString() + ParsedCmd; 112 | return CheatManagerObj->CallFunctionByNameWithArguments(*CmdString, Ar, Executor, bForceCallWithNonExec); 113 | } 114 | -------------------------------------------------------------------------------- /Source/MetaCheatManager/Public/MetaCheatCommand.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Yevhenii Selivanov 2 | 3 | #pragma once 4 | 5 | #include "CoreMinimal.h" 6 | #include "MetaCheatCommand.generated.h" 7 | 8 | struct FAutoCompleteCommand; 9 | 10 | /** 11 | * Describes a cheat command. 12 | */ 13 | USTRUCT(BlueprintType) 14 | struct METACHEATMANAGER_API FMetaCheatCommand 15 | { 16 | GENERATED_BODY() 17 | 18 | /** Contains empty cheat command. */ 19 | static const FMetaCheatCommand EmptyCommand; 20 | 21 | /** The name of command that will be displayed in console. */ 22 | UPROPERTY(EditAnywhere, BlueprintReadWrite) 23 | FName CheatName = NAME_None; 24 | 25 | /** The original name of function. */ 26 | UPROPERTY(EditAnywhere, BlueprintReadWrite) 27 | FName FunctionName = NAME_None; 28 | 29 | /** The description of the command. */ 30 | UPROPERTY(EditAnywhere, BlueprintReadWrite) 31 | FName CheatDescription = NAME_None; 32 | 33 | /** Returns true if this command contains correct data */ 34 | FORCEINLINE bool IsValid() const 35 | { 36 | return CheatName != NAME_None 37 | && CheatDescription != NAME_None 38 | && FunctionName != NAME_None; 39 | } 40 | 41 | /** Returns the Auto Complete Command from this structure object. */ 42 | FAutoCompleteCommand ToAutoCompleteCommand() const; 43 | 44 | #if WITH_EDITOR 45 | /** Builds all the data for this command by function ptr. 46 | * Is editor-only since the meta data is not available in the build.*/ 47 | static FMetaCheatCommand Create(const UFunction* InFunction); 48 | 49 | /** Finds a value of the 'CheatName' meta data for the specified function, none if CheatName is not set. 50 | * Is editor-only since the meta data is not available in the build.*/ 51 | static FName FindCheatMetaData(const UFunction* InFunction); 52 | 53 | /** Finds the description for the specified function. 54 | * Is editor-only since the meta data is not available in the build.*/ 55 | static FName FindCheatDescription(const UFunction* InFunction); 56 | #endif // WITH_EDITOR 57 | }; 58 | -------------------------------------------------------------------------------- /Source/MetaCheatManager/Public/MetaCheatManager.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Yevhenii Selivanov 2 | 3 | #pragma once 4 | 5 | #include "GameFramework/CheatManager.h" 6 | #include "MetaCheatManagerInterface.h" 7 | //--- 8 | #include "MetaCheatCommand.h" 9 | //--- 10 | #include "MetaCheatManager.generated.h" 11 | 12 | /** 13 | * The Meta Cheat Manager plugin introduces a feature to Unreal Engine 5 14 | * that allows you to call cheat functions with custom meta names from the console command, 15 | * similar to the 'Your.Cheat.Name' format. This functionality helps replace the 16 | * 'meta=(OverrideNativeName="Your.Cheat.Name"))' feature, which was available in Unreal Engine 4 17 | * but became unavailable in Unreal Engine 5 due to the removal of Blueprint Nativization. 18 | * 19 | * To use this feature, follow these steps: 20 | * 21 | * Step 1: Create a new class that inherits from UMetaCheatManager (not 'UCheatManager'). 22 | * 23 | * Step 2: In your Player Controller's constructor, set your new cheat manager: 24 | * ``` 25 | * AMyPlayerController::AMyPlayerController() 26 | * { 27 | * CheatClass = UMyCheatManager::StaticClass(); 28 | * } 29 | * ``` 30 | * Step 3: Add meta=(CheatName="Your.Cheat.Name") to your subclass's functions to 31 | * customize command names, for example: 32 | * ``` 33 | * UFUNCTION(meta = (CheatName = "Your.Cheat.Name")) 34 | * void YourCheatFunction(); 35 | * ``` 36 | * Things to keep in mind: 37 | * - The 'Exec' specifier is not required for these functions. This differs from the 38 | * default cheat manager where it's necessary. In this case, 'CheatName' automatically 39 | * implies these are 'Exec' functions. 40 | * - This setup works even if you have your cheat manager implemented only in code. 41 | * However, you can also have an inherited blueprint if you prefer. 42 | * - Upon editor startup, the plugin automatically creates a DefaultMetaCheatManager.ini 43 | * config. This file, stored in your project's Config folder, ensures your custom cheat 44 | * commands work in the packaged build without any extra steps on your part. This is 45 | * necessary as metadata can only be read in the Editor, so it's saved in the config file 46 | * for the build. 47 | */ 48 | UCLASS(Config = "MetaCheatManager", DefaultConfig) 49 | class METACHEATMANAGER_API UMetaCheatManager : public UCheatManager 50 | , public IMetaCheatManagerInterface 51 | { 52 | GENERATED_BODY() 53 | 54 | public: 55 | /** Returns all cheat commands exposed by this cheat manager. 56 | * @see UMetaCheatManager::AllCheatCommands */ 57 | virtual const FORCEINLINE TArray& GetAllCheatCommands() const override { return AllCheatCommands; } 58 | 59 | protected: 60 | /** Contains all cheat commands exposed by this cheat manager. 61 | * Is automatically saved into config file while in editor to have these commands available in builds where is no access to meta data. */ 62 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Config, meta = (BlueprintProtected)) 63 | TArray AllCheatCommands; 64 | 65 | /** Is overridden to initialize all cheat commands on editor startup. */ 66 | virtual void PostInitProperties() override; 67 | 68 | /** Is overridden to convert a meta CheatName 'Your.Cheat.Name' 69 | * to the function name 'YourCheatFunction' to process the call whenever user enters the command. */ 70 | virtual bool ProcessConsoleExec(const TCHAR* Cmd, FOutputDevice& Ar, UObject* Executor) override; 71 | 72 | /** Garbage things before destroying the Cheat Manager. */ 73 | virtual void BeginDestroy() override; 74 | 75 | /** Is bound to return all initialized meta cheat commands to see them in the console. */ 76 | virtual void RegisterAutoCompleteEntries(TArray& OutCommands) const override; 77 | }; 78 | -------------------------------------------------------------------------------- /Source/MetaCheatManager/Public/MetaCheatManagerExtension.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Yevhenii Selivanov 2 | 3 | #pragma once 4 | 5 | #include "GameFramework/CheatManager.h" 6 | #include "MetaCheatManagerInterface.h" 7 | //--- 8 | #include "MetaCheatCommand.h" 9 | //--- 10 | #include "MetaCheatManagerExtension.generated.h" 11 | 12 | /** 13 | * Allows to call commands with meta names for Extensions as well. 14 | * This could be useful for plugins and Game Feature modules that are populating their own cheats. 15 | * 16 | * Similar to UMetaCheatManager, UMetaCheatManagerExtension provides functionality to handle 17 | * cheat commands with custom meta names from the console command, giving flexibility for 18 | * modular cheat management across different modules of the game. 19 | */ 20 | UCLASS(Config = "MetaCheatManager", DefaultConfig) 21 | class METACHEATMANAGER_API UMetaCheatManagerExtension : public UCheatManagerExtension 22 | , public IMetaCheatManagerInterface 23 | { 24 | GENERATED_BODY() 25 | 26 | public: 27 | /** Returns all cheat commands exposed by this cheat manager. 28 | * @see UMetaCheatManager::AllCheatCommands */ 29 | virtual const FORCEINLINE TArray& GetAllCheatCommands() const override { return AllCheatCommands; } 30 | 31 | protected: 32 | /** Contains all cheat commands exposed by this cheat manager. 33 | * Is automatically saved into config file while in editor to have these commands available in builds where is no access to meta data. */ 34 | UPROPERTY(EditAnywhere, BlueprintReadWrite, Config, meta = (BlueprintProtected)) 35 | TArray AllCheatCommands; 36 | 37 | /** Is overridden to initialize all cheat commands on startup. */ 38 | virtual void PostInitProperties() override; 39 | 40 | /** Is overridden to convert a meta CheatName 'Your.Cheat.Name' 41 | * to the function name 'YourCheatFunction' to process the call whenever user enters the command. */ 42 | virtual bool ProcessConsoleExec(const TCHAR* Cmd, FOutputDevice& Ar, UObject* Executor) override; 43 | 44 | /** Garbage things before destroying the Cheat Manager. */ 45 | virtual void BeginDestroy() override; 46 | 47 | /** Is bound to return all initialized meta cheat commands to see them in the console. */ 48 | virtual void RegisterAutoCompleteEntries(TArray& OutCommands) const override; 49 | }; 50 | -------------------------------------------------------------------------------- /Source/MetaCheatManager/Public/MetaCheatManagerInterface.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Yevhenii Selivanov 2 | 3 | #pragma once 4 | 5 | #include "UObject/Interface.h" 6 | //--- 7 | #include "MetaCheatManagerInterface.generated.h" 8 | 9 | struct FMetaCheatCommand; 10 | 11 | // This class does not need to be modified. 12 | UINTERFACE(MinimalAPI, BlueprintType, NotBlueprintable) 13 | class UMetaCheatManagerInterface : public UInterface 14 | { 15 | GENERATED_BODY() 16 | }; 17 | 18 | /** 19 | * Interface for classes that manage meta cheat commands. 20 | * Provides a blueprint-exposed method to retrieve all cheat commands. 21 | * In general, is helpful when working with Cheat Manager classes. 22 | */ 23 | class METACHEATMANAGER_API IMetaCheatManagerInterface 24 | { 25 | GENERATED_BODY() 26 | 27 | public: 28 | /** Returns the array of cheat commands. */ 29 | UFUNCTION(BlueprintCallable, Category = "C++") 30 | virtual const TArray& GetAllCheatCommands() const = 0; 31 | 32 | /** It has to be bound to UConsole::RegisterConsoleAutoCompleteEntries to register the cheat in the console. */ 33 | virtual void RegisterAutoCompleteEntries(TArray& OutCommands) const = 0; 34 | }; 35 | -------------------------------------------------------------------------------- /Source/MetaCheatManager/Public/MetaCheatManagerModule.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Yevhenii Selivanov. 2 | 3 | #pragma once 4 | 5 | #include "Modules/ModuleInterface.h" 6 | 7 | class METACHEATMANAGER_API FMetaCheatManagerModule : public IModuleInterface 8 | { 9 | public: 10 | /** 11 | * Called right after the module DLL has been loaded and the module object has been created. 12 | * Load dependent modules here, and they will be guaranteed to be available during ShutdownModule. 13 | */ 14 | virtual void StartupModule() override; 15 | 16 | /** 17 | * Called before the module is unloaded, right before the module object is destroyed. 18 | * During normal shutdown, this is called in reverse order that modules finish StartupModule(). 19 | * This means that, as long as a module references dependent modules in it's StartupModule(), it 20 | * can safely reference those dependencies in ShutdownModule() as well. 21 | */ 22 | virtual void ShutdownModule() override; 23 | }; 24 | -------------------------------------------------------------------------------- /Source/MetaCheatManager/Public/MetaCheatManagerUtils.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Yevhenii Selivanov 2 | 3 | #pragma once 4 | 5 | #include "Kismet/BlueprintFunctionLibrary.h" 6 | //--- 7 | #include "MetaCheatManagerUtils.generated.h" 8 | 9 | struct FMetaCheatCommand; 10 | 11 | class IMetaCheatManagerInterface; 12 | 13 | /** 14 | * Utility class for shared meta cheat manager functions. 15 | * Contains static methods used by classes that manage meta cheat commands. 16 | */ 17 | UCLASS() 18 | class METACHEATMANAGER_API UMetaCheatManagerUtils : public UBlueprintFunctionLibrary 19 | { 20 | GENERATED_BODY() 21 | 22 | public: 23 | /** Finds and saves all cheat commands marked with 'CheatName' metadata. 24 | * @warning its implementation is editor-only since we don't have access to any meta data in builds. */ 25 | UFUNCTION(BlueprintCallable, Category = "C++") 26 | static void InitAllCheatCommands(const TScriptInterface CheatManager, TArray& OutAllCheatCommands); 27 | 28 | /** Returns the cheat command associated with specified CheatName meta value. */ 29 | UFUNCTION(BlueprintPure, Category = "C++") 30 | static const FMetaCheatCommand& GetCheatCommandByCheatName(FName CheatName, const TArray& InAllCheatCommands); 31 | 32 | /** Registers auto-complete entries for the cheat commands. */ 33 | static void RegisterAutoCompleteEntries(TArray& OutCommands, const TArray& InAllCheatCommands); 34 | 35 | /** Processes the console execution of meta cheat commands. */ 36 | static bool TryProcessConsoleExec(const TScriptInterface& CheatManager, const TCHAR* const Cmd, FOutputDevice& Ar, UObject* Executor); 37 | }; 38 | --------------------------------------------------------------------------------