TrainerKit is an extract of the Feature-system developed for EscapeFromTarkov-Trainer for games compiled with the Mono backend. For the Il2Cpp backend, you can use TrainerKit-Il2Cpp.
TrainerKit simplifies the development of internal Unity trainers by handling:
- UI rendering of features (everything is done automatically through reflection). Support for
Color,Float,Int,String,Bool,KeyCodetypes. - Load/save of settings.
- Runtime execution of Features.
- Injection into target process.
Starting with TrainerKit codebase, simply write the following code:
usingTrainerKit.Features;usingTrainerKit.Properties;usingUnity.FPS.Game;namespaceTrainerKit.DemoFPS;internalclassGodMode:ToggleFeature{publicoverridestringName=>Strings.FeatureGodModeName;publicoverridestringDescription=>Strings.FeatureGodModeDescription;protectedoverridevoidUpdateWhenEnabled(){varhealth=Object.FindFirstObjectByType<Health>();health?.Invincible=true;}protectedoverridevoidUpdateWhenDisabled(){varhealth=Object.FindFirstObjectByType<Health>();health?.Invincible= false;}}and
usingTrainerKit.Configuration;usingTrainerKit.Features;usingTrainerKit.Properties;usingUnity.FPS.Game;usingUnityEngine;namespaceTrainerKit.DemoFPS;internalclassUnlimitedAmmo:ToggleFeature{publicoverridestringName=>Strings.FeatureUnlimitedAmmoName;publicoverridestringDescription=>Strings.FeatureUnlimitedAmmoDescription;[ConfigurationProperty]publicintDemoInt{get;set;}=999;[ConfigurationProperty]publicColorDemoColor{get;set;}=Color.red;[ConfigurationProperty]publicstringDemoText{get;set;}="Text";[ConfigurationProperty]publicKeyCodeDemoKey{get;set;}=KeyCode.Alpha0;[ConfigurationProperty]publicfloatDemoFloat{get;set;}=3.14f;protectedoverridevoidUpdateWhenEnabled(){varweapon=Object.FindFirstObjectByType<WeaponController>();weapon?.MaxAmmo=int.MaxValue;}protectedoverridevoidUpdateWhenDisabled(){varweapon=Object.FindFirstObjectByType<WeaponController>();weapon?.MaxAmmo=8;}}and the system will automatically generate the following window after injecting into the target process (use RightAlt by default to display the menu):
Note that the system displays names like !! [Id] !! because it couldn't find the corresponding entries in the resource file (for example PropertyDemoInt for DemoInt):
The following configuration file can be automatically generated (and reloaded on next execution):
; Be careful when updating this file :); For keys, use https://docs.unity3d.com/ScriptReference/KeyCode.html; Colors are stored as an array of 'RGBA' floatsTrainerKit.DemoFPS.GodMode.Enabled=true
TrainerKit.DemoFPS.GodMode.Key="None"TrainerKit.DemoFPS.UnlimitedAmmo.Enabled=true
TrainerKit.DemoFPS.UnlimitedAmmo.Key="None"TrainerKit.DemoFPS.UnlimitedAmmo.DemoColor=[1.0,0.0,0.0,1.0]
TrainerKit.DemoFPS.UnlimitedAmmo.DemoFloat=3.14
TrainerKit.DemoFPS.UnlimitedAmmo.DemoInt=999
TrainerKit.DemoFPS.UnlimitedAmmo.DemoKey="Alpha0"TrainerKit.DemoFPS.UnlimitedAmmo.DemoText="Text"TrainerKit.Features.Commands.Key="RightAlt"TrainerKit.Features.Commands.ConsoleColor=[1.0,1.0,1.0,1.0]
TrainerKit.Features.Commands.X=462.0
TrainerKit.Features.Commands.Y=10.01- Starting from the source code, add the necessary references to the game you want to mod. You need at least:
UnityEngine
UnityEngine.CoreModule
UnityEngine.IMGUIModule
UnityEngine.InputLegacyModule
UnityEngine.TextRenderingModule
2- Write your Features, starting from:
HoldFeature
ToggleFeature
TriggerFeature
Decorate your own properties with ConfigurationPropertyAttribute. This will expose your property to rendering and persistence. You can finetune the behavior by using dedicated settings:
[AttributeUsage(AttributeTargets.Property)]publicclassConfigurationPropertyAttribute:Attribute{// Skip completely (Rendering+Config), useful when overriding propertiespublicboolSkip{get;set;}=false;// Dislay orderpublicintOrder{get;set;}=int.MaxValue;// Link a resource id for generating comment in the ini filepublicstringCommentResourceId{get;set;}=string.Empty;// Enable/Disable renderingpublicboolBrowsable{get;set;}=true;}3- Compile. If you need extra dependencies, you can either add them in the Managed folder of the target game, or il-merge everything into one unique assembly (we already use ILRepack to add a compatible Newtonsoft.Json assembly).
4- Run the executable, it will handle the injection into the target process (see Program.cs to customize the target):
publicstaticvoidMain(){try{varlocation=Assembly.GetEntryAssembly()!.Location;varbytes=File.ReadAllBytes(location);conststringprocessName="TODO";usingvarinjector=newInjector(processName);varintptr=injector.Inject(bytes,typeof(Context).Namespace,nameof(Context),nameof(Context.Load));Console.WriteLine(Strings.InjectorSuccess,Path.GetFileName(location),processName,injector.Is64Bit?$"0x{intptr.ToInt64():X16}":$"0x{intptr.ToInt32):X8}");}catch(Exceptione){Console.WriteLine(Strings.InjectorFailure,e.Message);}}Here is the output, but you can still use your preferred Mono injector.
Injected TrainerKit.exe into process FPS: 0x000002B0E9099380
Indeed if we have a look at the TrainerKit.Context.Load method, we can see the registration logic:
publicstaticvoidLoad(){vargo=newGameObject(nameof(Context));UnityEngine.Object.DontDestroyOnLoad(go);FeatureFactory.RegisterAllFeatures(go);varcommands=FeatureFactory.GetFeature<Commands>();if(commands==null)return;AddConsoleLog(Strings.FeatureRendererWelcome+$" ({commands.Key})");}If you hit any issue while injecting, make sure you are not missing any dependencies.
EscapeFromTarkov-Trainer for Escape From Tarkov game. Before switching to IL2CPP.
- No
ILRepacking: specificBepInExinjector, andNewtonSoft.Jsontypes are directly provided by the game assemblies. Compiled for netfx4.7.1 MonoBackend.- Using Unity
2022.3.43f1.
- No
DiscoElysium-Trainer for Disco Elysium game.
Il2CppBackend.- Using Unity
2020.3.12f1.
IronCast-Trainer for IronCast game.
- No
ILRepacking: standaloneSharpMonoInjector, andNewtonSoft.Jsontypes are directly provided by the game assemblies. MonoBackend.- Using Unity
4.6.1f1, so compiled for netfx3.5, requiring minor code adaptations.
- No
Megabonk-Trainer for Megabonk game.
Il2CppBackend.- Using Unity
2023.2.22f1.
MonstersAreComing-Trainer for Monsters Are Coming game.
Il2CppBackend.- New Input System.
- Using Unity
2022.3.62f2.
YAZDHD-Trainer for Yet Another Zombie Defense HD game.
ILRepackingto provideSharpMonoInjectoras a built-in injector, andNewtonSoft.Jsontypes internalized. Compiled for netfx4.8.1.MonoBackend.- Using Unity
2019.4.13f1.
The demo Unity's FPS Microgame used here.
- With
Monobackend,ILRepackingto provideSharpMonoInjectoras a built-in injector, andNewtonSoft.Jsontypes internalized. Compiled for netfx4.8.1. - With
Il2Cppbackend. - Using Unity
2022.3.62f3.
- With

