Tutorial How to inject mod menu into DLL based Unity games (Mono backend ONLY)

AndnixSH

PMT Elite Modder
Staff member
Modding-Team


I have impoved the flat menu with the following changes:
- Auto resize width
- Auto resize height wieh adding/removing buttons
- Note/warning box
- Better dragging menu by bringing back WindowFunction
If you already using flat mod menu, please use the new code.

Download source code:

AndnixSH/UnityModMenuAndroid

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 Unity
Go to Store - Unity Store 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:

vKf69Kk.png


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

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

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

C#:
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

D2GxpoG.png


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

pWLfYOg.png


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...

8RwLWyU.png


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:

C#:
public void OnGUI()
{
    YourModMenu.OnGUI();
}
If OnGUI() exists, edit it and only add
C#:
YourModMenu.OnGUI();

o6wLN3H.png


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

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

And In void

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

wgP7e6F.png


There are many ways to modify

Save the dll file and test your mod menu

Good luck :)

Preview:
o3FKJo8.png


Mod menu in action:
 
Last edited:

Here's a highly customized version of this menu. Known AndnixSH for a damn long time now, his work is always amazing. Keep it up man.

The only things I might suggest adding for new people to this is some simple way to make the Menu bigger in games. Some sort of like public static int menuSizeMultiplier; sort of thing that makes the whole thing bigger. If I get it working myself, I'll share it here

I'll add image after I remove my accidental advertisement from the SS
 
Nice bro keep it up, but do you have some more simple mod menu? I'm just a newbie and I make mod for my personal use cause my mod can ban someone, I don't know how to add Anti-Ban hehehe
I have the older one but the design is crappy. I'll work with improvement of this menu and keep it simple as possible.
About anti-ban, it's not really anti-ban, they simply spoofing or removing ban in order to continue playing the game.
 
@Zhard all your methods must be static in your mod menu code (public static void YourMethod). It's explained in code template
 
@Zhard I said 'your' mod menu code, not in existing classes lol
In YuH, add static to OnGUI, ModMenuGUI and Logo.
Since some modders don't read my code comments and are confusing with static thing, I'll update my code in github again
 
Hi AndnixSH,

Thank you for your time + patient.

I finally got it to register but it wont appear in the game.

I did the test button and it appear as white text.

I then add the script, all registered but the button do not show up.

1540959778807.png

1540959819864.png

1540959885774.png
 
Hi AndniSH,

Is there a way to resize the menu like how you did to the :

public static float delay = 0, widthSize = 300; // Change whole width size of menu here

maybe smaller box? (height)

1541653563290.png
 
Back
Top Bottom