[Tutorial] Simple Mod Menu + Cheat codes for PC Unity game


I made it for fun, It’s not for Android lol


You can use the code whatever you want without crediting to me. It’s not copyrighted or licensed

Please note, you must have basic knowledge of C# and Unity. I won’t explain everything in it.
And don’t forget the read everything, being lazy to read and skipping will cause yourself to do bad things. And if you still have question after fully reading, just ask.

Using Unity editor to customize and test:
It’s better to customize it in Unity editor and test. You can edit code while the scene is playing

First, create an account or sign in with Google or Facebook at https://unity3d.com/

Go to https://store.unity.com/ and select "Try personal". It is completely free. Download and install it. If you like to have Visaul Studio 2017 installed, make sure to select it in installer. If not installed, you will use MonoDevelop.

Launch Unity, login with your account and complete your survey. After that you can create a new project. Name it you want and keep 3D selected and disable Unity Analytics. Click "Create project"

To add the existing script, simply drop the .cs file on Protect/Assets section

Everything are explained in source code

It’s recommended to create mod menu script each games you want to mod like I do so you have your scripts ready for modding:


How to add mod menu into the game:
This is a tricky part because you need to find classes that are active. it’s hard to find, but there are ways to find out and add OnGUI.

- Known active classes are UIRoot, UIDrawcall, SoundManager, AudioManager, Loading classes etc... The best are SoundManager, AudioManager or something similar

- Search for any "Start" or "Awake" method, add this code and change first number +50 each Classes that have "Start" or "Awake" method to find out what classes is active and best

void OnGUI() {
GUI.Button(new Rect(0,0,200,50), "FirstClassName");
}

void OnGUI() {
GUI.Button(new Rect(50,0,200,50), "FirstClassName2");
}

void OnGUI() {
GUI.Button(new Rect(100,0,200,50), "FirstClassName3");
}

You can just edit any method and add OnGUI code above and it will add into Class

 

If the button is too dark, that’s a bad class.

In this case, i’m modding Baldi’s Basics and added OnGUI to PlayerScript, PlaytimeScript and ScoreScript. Only 1 button “PlayerScript” appear on screen so we know it’s an active class


If you found a good active class that isn’t bad, you can start adding mod menu

Right click on empty namespace and click Add Class...


Add your whole code. Make sure the OnGUI() and Update() is “public static” so other classes can access the fields. Click Compile

dnSpy can't find class you created so you have to save the assembly as Assembly-CSharp.dll in Managed folder. Unload Assembly-CSharp.dll and reload Assembly-CSharp.dll file

Now call OnGUI and Update on active class to your mod menu
On active class, if OnGUI() or Update() does not exists, just edit one of method and add new method above or below existing method:

public void OnGUI()
{
    YourModMenu.OnGUI();
}


If OnGUI() or Update() exists, edit it and only add

YourModMenu.Method();


Hacking functions with mod menu
Now search some functions to hack. If you had added OnGUI in an existing class with Instance method, modify the code like this:
In this case, I modify getter method


public float ArmorCapacity
{
    get
    {
        if (YourModMenu.toggle1)
        {
            return 999f;
        }
        return this._armorCapacity;
    }
}

And In void


private void Success()
{
   if (YourModMenu.toggle2)
   {
       if (this.jumps >= 10)
       {
       // success code
       }
   }
   else if (this.jumps >= 5)
   {
   // success code
   }
}


There are many ways to modify

Save the dll file and test your mod menu

Good luck :)

Preview:
I use Baldi’s Basics as an example because it’s quickest way to test mod menu

Popular Posts

[TOOL] Unity Assets Bundle Extractor

Il2CppDumper GUI Android App