MelonLoader
The World's First Universal Mod Loader for Unity Games compatible with both Il2Cpp and Mono
Top Related Projects
Unity / XNA game patcher and plugin framework
A library for patching, replacing and decorating .NET and Mono methods during runtime
An in-game UI for exploring, debugging and modifying IL2CPP and Mono Unity games.
Quick Overview
MelonLoader is an open-source mod loader for Unity games. It allows users to load and manage mods for Unity-based games, providing a framework for modders to create and distribute custom content and modifications.
Pros
- Cross-platform support (Windows, Linux, Android)
- Automatic updates and mod management
- Extensive documentation and active community support
- Compatible with a wide range of Unity games
Cons
- May not work with all Unity games, especially those with strong anti-cheat systems
- Potential for conflicts between mods
- Requires some technical knowledge to set up and use effectively
- May impact game performance, especially with multiple mods installed
Code Examples
// Example 1: Creating a simple mod
using MelonLoader;
public class MyMod : MelonMod
{
public override void OnApplicationStart()
{
LoggerInstance.Msg("My mod has been loaded!");
}
}
// Example 2: Hooking into a game method
using HarmonyLib;
[HarmonyPatch(typeof(PlayerController), "TakeDamage")]
public class DamageModifier
{
[HarmonyPostfix]
public static void Postfix(ref float __result)
{
__result *= 0.5f; // Reduce damage taken by 50%
}
}
// Example 3: Adding a custom GUI element
using UnityEngine;
public class CustomGUI : MelonMod
{
public override void OnGUI()
{
GUI.Label(new Rect(10, 10, 100, 20), "Hello, MelonLoader!");
}
}
Getting Started
- Download the latest MelonLoader installer from the official GitHub repository.
- Run the installer and select the Unity game executable you want to mod.
- Create a new C# project in your preferred IDE.
- Add references to
MelonLoader.dll
and0Harmony.dll
from the game's installation folder. - Create a new class that inherits from
MelonMod
:
using MelonLoader;
public class MyFirstMod : MelonMod
{
public override void OnApplicationStart()
{
LoggerInstance.Msg("Hello, MelonLoader!");
}
}
- Build your project and place the resulting DLL in the game's
Mods
folder. - Launch the game to see your mod in action.
Competitor Comparisons
Unity / XNA game patcher and plugin framework
Pros of BepInEx
- More flexible and supports a wider range of Unity games
- Better documentation and community support
- Offers a plugin system for easier mod management
Cons of BepInEx
- Slightly more complex setup process
- May have compatibility issues with some older games
- Performance impact can be higher in certain scenarios
Code Comparison
MelonLoader:
[MelonInfo(typeof(MyMod), "MyMod", "1.0.0", "Author")]
public class MyMod : MelonMod
{
public override void OnApplicationStart()
{
// Mod initialization code
}
}
BepInEx:
[BepInPlugin("com.example.myplugin", "MyPlugin", "1.0.0")]
public class MyPlugin : BaseUnityPlugin
{
private void Awake()
{
// Plugin initialization code
}
}
Both MelonLoader and BepInEx are popular modding frameworks for Unity games. MelonLoader is known for its ease of use and straightforward setup, while BepInEx offers more flexibility and broader game support. The code comparison shows that both frameworks use similar attribute-based mod/plugin registration, but with slightly different class inheritance and initialization methods. Ultimately, the choice between the two depends on the specific game being modded and the developer's preferences.
A library for patching, replacing and decorating .NET and Mono methods during runtime
Pros of Harmony
- More lightweight and focused on patching .NET methods
- Easier to integrate into existing projects without full mod loader overhead
- Better documentation and community support
Cons of Harmony
- Limited to method patching, lacks broader mod management features
- Requires more manual setup and configuration for each patch
- Less suitable for large-scale modding projects or game-specific modifications
Code Comparison
MelonLoader:
[MelonLoader.MelonInfo(typeof(MyMod), "MyMod", "1.0.0", "Author")]
public class MyMod : MelonLoader.MelonMod
{
public override void OnInitializeMelon()
{
// Mod initialization code
}
}
Harmony:
[HarmonyPatch(typeof(TargetClass), "TargetMethod")]
class Patch
{
static void Postfix(ref int __result)
{
__result *= 2; // Modify the result
}
}
MelonLoader provides a more comprehensive modding framework with built-in mod management and lifecycle hooks, while Harmony focuses on efficient method patching. MelonLoader is better suited for large-scale game modding, whereas Harmony excels in targeted modifications and library integrations.
An in-game UI for exploring, debugging and modifying IL2CPP and Mono Unity games.
Pros of UnityExplorer
- More focused on runtime inspection and debugging of Unity games
- Provides a comprehensive in-game UI for exploring and manipulating game objects
- Offers advanced features like object browser, scene explorer, and console commands
Cons of UnityExplorer
- Limited to runtime exploration and modification
- May not provide as extensive modding capabilities as MelonLoader
- Potentially higher performance impact due to real-time inspection features
Code Comparison
UnityExplorer:
public static void Init()
{
UIManager.Init();
ObjectExplorer.Init();
SceneExplorer.Init();
}
MelonLoader:
public override void OnApplicationStart()
{
ModLogger.Log("Mod initialized!");
// Custom mod initialization code
}
UnityExplorer focuses on providing runtime inspection and debugging tools, while MelonLoader is primarily designed for modding Unity games. UnityExplorer's code snippet shows initialization of various exploration tools, whereas MelonLoader's code demonstrates a typical mod entry point. MelonLoader offers a more comprehensive framework for creating and loading mods, while UnityExplorer excels at runtime analysis and manipulation of Unity games.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
GENERAL INFORMATION:
- Debug Mode is for Development Purposes.
Use it to help Develop and Debug MelonLoader, Plugins, and Mods. - All Logs are made in the created
MelonLoader/Logs
folder in your Game's Installation Folder. - All Plugins get placed in the created
Plugins
folder in your Game's Installation Folder. - All Mods get placed in the created
Mods
folder in your Game's Installation Folder. - The Official Wiki
- Proxies
- Launch Options
- Debugging
- Linux Support (WINE / STEAM PROTON / NATIVE)
- Android & Oculus Quest Support (WIP)
Usage Guides: |
---|
INSTALLER |
MANUAL USE |
Example Projects: |
---|
TestPlugin |
TestMod |
Nightly Builds: |
---|
master |
alpha-development |
universality |
â¤ï¸ SPECIAL THANKS TO OUR WONDERFUL PATRONS â¤ï¸
- Givo
- Florian Fahrenberger
- Python
- SirCoolness
- SlidyDev
REQUIREMENTS:
- .NET Framework 3.5 Runtime
- .NET Framework 4.7.2 Runtime
- .NET Framework 4.8 Runtime
- .NET 6.0 Desktop Runtime
- Microsoft Visual C++ 2015-2019 Re-distributable [x86] [x64]
HOW TO USE THE INSTALLER:
- Follow the Instructions in one of the Guides linked below.
Installer Guides: |
---|
INSTALL |
UPDATE |
RE-INSTALL |
UN-INSTALL |
HOW TO MANUALLY USE MELONLOADER:
UPDATE / RE-INSTALL:
- Follow the Steps to UN-INSTALL
- Follow the Steps to INSTALL
INSTALL:
- Make sure the Game is Closed and Not Running before attempting to Install.
- Make sure you have all the Requirements Installed before attempting to Install.
- Download MelonLoader [x86] [x64]
- Extract the MelonLoader folder from the MelonLoader Zip Archive to the Game's Installation Folder.
- Extract version.dll & dobby.dll from the MelonLoader Zip Archive to the Game's Installation Folder.
UN-INSTALL:
- Make sure the Game is Closed and Not Running before attempting to UN-INSTALL.
- Remove the version.dll & dobby.dll files from the Game's Installation Folder.
- Remove the MelonLoader folder from the Game's Installation Folder.
These additional steps below are OPTIONAL if you want to do a FULL UN-INSTALL.
- Remove the Plugins folder from the Game's Installation Folder.
- Remove the Mods folder from the Game's Installation Folder.
- Remove the UserData folder from the Game's Installation Folder.
START SCREEN CUSTOMIZATION:
-
After Initial Launch the Start Screen will create a folder under
UserData/MelonStartScreen
-
Inside this folder it will create a
Themes
folder and aConfig.cfg
file for Customization Settings. -
You can also place Custom Themes in the created
Themes
folder. -
Inside
Config.cfg
you can set what Theme folder you would like to use. -
If you set your Theme folder to
Random
it will randomly pick and load from existing Themes. -
For Custom Themes you can place Custom Images in their Theme folder to further customize it.
-
Listed below are the Compatible File Names and Extensions for the Custom Images.
Compatible File Names |
---|
Background |
Loading |
Logo |
Compatible Extensions |
---|
.gif |
.png |
.jpg |
.jpeg |
LAUNCH OPTIONS:
- These are additional Launch Options that MelonLoader adds to the Game.
- These can be used to manipulate how MelonLoader works.
Argument | Description |
---|---|
--no-mods | Launches the Game without loading any Plugins or Mods |
--quitfix | Fixes the Hanging Process Issue with some Games |
--melonloader.consolemode | Changes the Theme Display Mode of the Console [ Default = 0 ] |
--melonloader.consoleontop | Forces the Console to always stay on-top of all other Applications |
--melonloader.consoledst | Keeps the Console Title as Original |
--melonloader.hideconsole | Hides the Console |
--melonloader.hidewarnings | Hides Warnings from Displaying |
--melonloader.debug | Debug Mode |
--melonloader.maxlogs | Max Log Files [ Default: 10 ] [ NoCap: 0 ] |
--melonloader.loadmodeplugins | Load Mode for Plugins [ Default: 0 ] |
--melonloader.loadmodemods | Load Mode for Mods [ Default: 0 ] |
--melonloader.basedir | Changes the Proxy's Load Directory for the Bootstrap |
--melonloader.disablestartscreen | Disable the Start Screen |
- These ones below are Unity Engine specific Launch Options.
Argument | Description |
---|---|
--melonloader.unityversion | Allows you to Specify the Version of Unity Engine |
--melonloader.agfoffline | Forces Assembly Generator to Run without Contacting the Remote API |
--melonloader.agfregenerate | Forces Regeneration of Assembly |
--melonloader.agfregex | Forces Assembly Generator to use a Specified Regex |
--melonloader.agfvdumper | Forces Assembly Generator to use a Specified Version of Dumper |
--melonloader.disableunityclc | Disable Unity Console Log Cleaner |
- These ones below are Cpp2IL specific Launch Options.
Argument | Description |
---|---|
--cpp2il.callanalyzer | Enables CallAnalyzer processor |
--cpp2il.nativemethoddetector | Enables NativeMethodDetector processor |
LOAD MODES:
- Load Mode Launch Options are a way to dictate how you want Mods or Plugins to Load.
- Below is the Compatible Values and what each of them do.
Value | Action |
---|---|
0 | Load Only if the File doesn't have the ".dev.dll" Extension |
1 | Load Only if the File has the ".dev.dll" Extension |
2 | Load All |
CONSOLE DISPLAY MODES:
- Console Display Modes are built in Themes for the Console
- Below is the Compatible Values and what each of them do.
Value | Mode |
---|---|
0 | Normal |
1 | Magenta |
2 | Rainbow |
3 | Random Rainbow |
PROXIES:
- The Proxy DLL is able to be Renamed to the Compatible File Names below.
- By Default the Proxy is named as "version.dll".
- For most Games the Default File Name should work perfectly fine.
- Some Games may have you use a different Proxy File Name depending on the Architecture, Operating System, version of the Engine used by the Game, etc.
File Names: |
---|
version.dll |
winhttp.dll |
winmm.dll |
LICENSING & CREDITS:
MelonLoader is licensed under the Apache License, Version 2.0. See LICENSE for the full License.
Third-party Libraries used as Source Code and/or bundled in Binary Form:
-
Dobby is licensed under the Apache License, Version 2.0. See LICENSE for the full License.
-
dobby-rs is licensed under the Apache License, Version 2.0. See LICENSE for the full License.
-
dobby-sys is licensed under the Apache License, Version 2.0. See LICENSE for the full License.
-
unity-rs is licensed under the Apache License, Version 2.0. See LICENSE for the full License.
-
Mono is licensed under multiple licenses. See LICENSE for full details.
-
HarmonyX is licensed under the MIT License. See LICENSE for the full License.
-
MonoMod is licensed under the MIT License. See LICENSE for the full License.
-
Mono.Cecil is licensed under the MIT License. See LICENSE for the full License.
-
Newtonsoft.Json is licensed under the MIT License. See LICENSE for the full License.
-
TinyJSON is licensed under the MIT License. See LICENSE for the full License.
-
Tomlet is licensed under the MIT License. See LICENSE for the full License.
-
AsmResolver is licensed under the MIT License. See LICENSE for the full License.
-
SharpZipLib is licensed under the MIT License. See LICENSE for the full License.
-
Semver is licensed under the MIT License. See LICENSE for the full License.
-
UnityEngine.Il2CppAssetBundleManager is licensed under the Apache License, Version 2.0. See LICENSE for the full License.
-
UnityEngine.Il2CppImageConversionManager is licensed under the Apache License, Version 2.0. See LICENSE for the full License.
-
Illusion Plugin Architecture is licensed under the MIT License. See LICENSE for the full License.
-
MuseDashModLoader is licensed under the MIT License. See LICENSE for the full License.
-
mgGif is licensed under the MIT License. See LICENSE for the full License.
-
AssetsTools.NET is licensed under the MIT License. See LICENSE for the full License.
-
AssetRipper.VersionUtilities is licensed under the MIT License. See LICENSE for the full License.
-
Steam Library, VDF, and ACF Parsing from SteamFinder.cs by Umbranoxio and Dalet.
-
bHapticsLib is licensed under the MIT License. See LICENSE for the full License.
-
IndexRange is licensed under the MIT License. See LICENSE for the full License.
-
ValueTupleBridge is licensed under the MIT License. See LICENSE for the full License.
-
WebSocketDotNet is licensed under the MIT License. See LICENSE for the full License.
-
Pastel is licensed under the MIT License. See LICENSE for the full License.
-
Il2CppInterop is licensed under the LGPLv3 License. See LICENSE for the full License.
External Libraries and Tools that are downloaded and used at Runtime:
- Cpp2IL is licensed under the MIT License. See LICENSE for the full License.
- Unity Runtime Libraries from Unity-Runtime-Libraries are part of Unity Software.
Their usage is subject to Unity Terms of Service, including Unity Software Additional Terms.
See MelonLoader Wiki for the full Credits.
MelonLoader is not sponsored by, affiliated with or endorsed by Unity Technologies or its affiliates.
"Unity" is a trademark or a registered trademark of Unity Technologies or its affiliates in the U.S. and elsewhere.
Top Related Projects
Unity / XNA game patcher and plugin framework
A library for patching, replacing and decorating .NET and Mono methods during runtime
An in-game UI for exploring, debugging and modifying IL2CPP and Mono Unity games.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot