MelonLoader Documentation

repository·master·Indexed 23 days ago

https://github.com/lavagang/melonloader

A mod loader for Unity games supporting Mono and Il2Cpp game types. This documentation covers manual installation, uninstallation, and configuration via Loader.cfg, as well as detailed launch options for general behavior, Unity Engine integration, and Cpp2IL. It also includes technical references for bundled libraries used for backwards compatibility, including SharpZipLib for compression, TinyJSON for JSON serialization, and the semver library for semantic version parsing.

Tokens
5.1K
Snippets
9
Records
23
Agent score
88%

What's inside MelonLoader

  1. Overview of SharpZipLib compression capabilities

    master

    SharpZipLib is a pure C# compression library that supports various archive and compression formats. It can be incorporated into any .NET project.

    Supported Formats and Methods:

    • Zip files: Supports both stored and deflate compression methods, PKZIP 2.0 style, and AES encryption. Supports Zip64 (Deflate64 is not supported).
    • Tar: Supports tar with GNU long filename extensions.
    • GZip, zlib, and raw deflate.
    • BZip2.
  2. MelonLoader Directory Structure

    master

    Once installed, MelonLoader creates the following folders in your game's installation directory:

    • MelonLoader/Logs: Contains all generated logs.
    • Plugins: Where all plugins are placed.
    • Mods: Where all mods are placed.
    • UserData: Contains configuration files like Loader.cfg.
  3. Uninstall MelonLoader manually

    master

    To uninstall MelonLoader manually:

    1. Ensure the game is closed and not running.
    2. Remove version.dll from the game's installation folder.
    3. Remove the MelonLoader folder from the game's installation folder.

    Optional for a full uninstall:

    • Remove the Plugins folder.
    • Remove the Mods folder.
    • Remove the UserData folder.
  4. Install MelonLoader manually

    master

    To install MelonLoader manually without the installer, follow these steps:

    1. Ensure the game is closed and not running.
    2. Verify all Requirements are installed.
    3. Download the MelonLoader Archive from the Releases page.
    4. Extract the MelonLoader folder from the archive into the game's installation folder.
    5. Extract version.dll and dobby.dll from the archive into the game's installation folder.
  5. Iterate over JSON collections using Proxy types

    master

    If you need to manually traverse a JSON structure, you can cast a Variant to specific proxy subclasses:

    • ProxyArray: For iterating over JSON arrays.
    • ProxyObject: For iterating over JSON objects (key-value pairs).
    • ProxyBoolean, ProxyNumber, ProxyString: For non-collection types.

    Note: A Variant can also be null.

    // Iterating an array
    var list = JSON.Load( "[1,2,3]" );
    foreach (var item in list as ProxyArray)
    {
    	int number = item;
    	Console.WriteLine( number );
    }
    
    // Iterating an object
    var dict = JSON.Load( "{\"x\":1,\"y\":2}" );
    foreach (var pair in dict as ProxyObject)
    {
    	float value = pair.Value;
    	Console.WriteLine( pair.Key + " = " + value );
    }
  6. Configure MelonLoader via Loader.cfg

    master

    MelonLoader configuration is stored in ./UserData/Loader.cfg. This file is generated after the first time you run MelonLoader. You can modify settings in the following sections: [loader], [console], [logs], [mono_debug_server], and [unityengine].

    [loader]
    # Disables MelonLoader. Equivalent to the '--no-mods' launch option
    disable = false
    # Equivalent to the '--melonloader.debug' launch option
    debug_mode = true
    # Capture all Unity player logs into MelonLoader's logs even if the game disabled them. NOTE: Depending on the game or Unity version, these logs can be overly verbose. Equivalent to the '--melonloader.captureplayerlogs' launch option
    capture_player_logs = true
    # The maximum Harmony log verbosity to capture into MelonLoader's logs. Possible values in verbosity order are: "None", "Error", "Warn", "Info", "Debug", or "IL". Equivalent to the '--melonloader.harmonyloglevel' launch option
    harmony_log_level = "Warn"
    # Only use this if the game freezes when trying to quit. Equivalent to the '--quitfix' launch option
    force_quit = false
    # Disables the start screen. Equivalent to the '--melonloader.disablestartscreen' launch option
    disable_start_screen = false
    # Starts the dotnet debugger on Windows and wait it is attached or just wait until one is attached without launch on other OSes (only for Il2Cpp games). Equivalent to the '--melonloader.launchdebugger' launch option
    launch_debugger = false
    # Sets the loader theme. Currently, the only available themes are "Normal" and "Lemon". Equivalent to the '--melonloader.consolemode' launch option (0 for Normal, 4 for Lemon)
    theme = "Normal"
    
    [console]
    # Hides warnings from displaying. Equivalent to the '--melonloader.hidewarnings' launch option
    hide_warnings = false
    # Hides the console. Equivalent to the '--melonloader.hideconsole' launch option
    hide_console = false
    # Forces the console to always stay on-top of all other applications. Equivalent to the '--melonloader.consoleontop' launch option
    console_on_top = false
    # Keeps the console title as original. Equivalent to the '--melonloader.consoledst' launch option
    dont_set_title = false
    
    [logs]
    # Sets the maximum amount of log files in the Logs folder (Default: 10). Equivalent to the '--melonloader.maxlogs' launch option
    max_logs = 10
    
    [mono_debug_server]
    # Let the Mono debug server wait until a debugger is attached when debug_mode is true (only for Mono games). Equivalent to the '--melonloader.debugsuspend' launch option
    debug_suspend = false
    # The IP address the Mono debug server will listen to when debug_mode is true (only for Mono games). Equivalent to the '--melonloader.debugipaddress' launch option
    debug_ip_address = "127.0.0.1"
    # The port the Mono debug server will listen to when debug_mode is true (only for Mono games). Equivalent to the '--melonloader.debugport' launch option
    debug_port = 55555
    
    [unityengine]
    # Overrides the detected UnityEngine version. Equivalent to the '--melonloader.unityversion' launch option
    version_override = ""
    # Disables the console log cleaner (only applies to Il2Cpp games). Equivalent to the '--melonloader.disableunityclc' launch option
    disable_console_log_cleaner = false
    # Forces the Il2Cpp Assembly Generator to run without contacting the remote API. Equivalent to the '--melonloader.agfoffline' launch option
    force_offline_generation = false
    # Forces the Il2Cpp Assembly Generator to use the specified regex. Equivalent to the '--melonloader.agfregex' launch option
    force_generator_regex = ""
    # Forces the Il2Cpp Assembly Generator to use the specified Il2Cpp dumper version. Equivalent to the '--melonloader.agfvdumper' launch option
    force_il2cpp_dumper_version = ""
    # Forces the Il2Cpp Assembly Generator to always regenerate assemblies. Equivalent to the '--melonloader.agfregenerate' launch option
    force_regeneration = false
    # Enables the CallAnalyzer processor for Cpp2IL. Equivalent to the '--cpp2il.callanalyzer' launch option
    enable_cpp2il_call_analyzer = false
    # Enables the NativeMethodDetector processor for Cpp2IL. Equivalent to the '--cpp2il.nativemethoddetector' launch option
    enable_cpp2il_native_method_detector = false
  7. Migrate from legacy MelonLoader.Main to modern APIs

    master

    The MelonLoader.Main class is deprecated and marked as obsolete. It is maintained solely for backwards compatibility and will be removed in a future update. Developers should migrate to the following modern alternatives:

    • Instead of MelonLoader.Main.Mods, use MelonLoader.MelonHandler.Mods.
    • Instead of MelonLoader.Main.Plugins, use MelonLoader.MelonHandler.Plugins.
    • Instead of MelonLoader.Main.IsBoneworks, use MelonLoader.MelonUtils.IsBONEWORKS.
    • Instead of MelonLoader.Main.GetUnityVersion(), use MelonLoader.InternalUtils.UnityInformationHandler.EngineVersion.
    • Instead of MelonLoader.Main.GetUserDataPath(), use MelonLoader.Utils.MelonEnvironment.UserDataDirectory.
  8. Reconstruct objects from JSON

    master

    To convert a Variant back into a concrete C# class or struct, you can use JSON.MakeInto<T> or the Make methods available on the Variant object itself.

    // Using MakeInto
    TestClass testClass;
    JSON.MakeInto( JSON.Load( testClassJson ), out testClass );
    
    // Using Variant.Make (alternative syntax)
    TestClass testClass;
    JSON.Load( json ).Make( out testClass );
    // or
    testClass = JSON.Load( json ).Make<Data>();