---
name: unity-il2cpp-modding
description: Build, inspect, and maintain Unity IL2CPP mods using MelonLoader, Harmony, C#, Rust FFI bridges, native cdylib plugins, type dumps, generated interop assemblies, runtime configuration, event systems, asset extraction, and compatibility testing. Use for Data Center, Greg framework and mods, UnityExplorer, Il2CppAssemblyFixer, LuaLoader, MelonLoader plugins, and game-version migration.
compatibility: Requires authorized local game files and development tooling. Do not bypass anti-cheat, access controls, licensing, multiplayer protections, or distribute copyrighted game assets.
license: Apache-2.0
---

# Unity IL2CPP modding

Treat game updates, generated interop assemblies, native ABI boundaries and Harmony patches as unstable interfaces that require explicit compatibility evidence.

## Required workflow

1. Record game build, Unity version, IL2CPP metadata version, MelonLoader version and target platform.
2. Reproduce the issue or feature request against a clean installation.
3. Regenerate or verify interop assemblies and type dumps after every relevant game update.
4. Locate target types and methods by stable evidence; do not rely only on stale offsets or names.
5. Design the smallest patch or wrapper with clear failure behavior.
6. Keep unsafe native and reflection access behind narrow APIs.
7. Build C# and Rust components with compatible calling conventions, layout, ownership and lifetime rules.
8. Test load, unload, save/load, scene changes, error paths and multiple mods.
9. Package only required binaries and documentation.
10. Report compatibility limits and exact tested versions.

## Rust and C# FFI

Define ABI versioning, struct size, alignment, ownership, nullability, string encoding, callback lifetime, panic/exception containment and thread requirements. Never unwind a Rust panic across FFI or allow unmanaged callbacks to outlive their C# owner. Validate exported symbol names and architecture.

## Harmony and events

Prefer stable semantic events over exposing raw game internals to every mod. Patch narrowly, avoid per-frame reflection and allocation, and handle missing methods without crashing the loader. Document event IDs, payload versions and ordering guarantees.

## Runtime configuration

Namespace configuration by mod ID, validate ranges, persist atomically, recover from malformed files and expose safe defaults. Do not allow arbitrary code or file paths through configuration values.

## Compatibility recovery

After engine or game changes, clear only generated caches known to be invalid, regenerate interop output, start once without optional mods, then reintroduce mods in controlled groups. Preserve user configuration and saves.

## Security and distribution

Do not include credentials, private game assemblies, paid assets or copyrighted dumps in releases. Scan dependencies and native binaries. Make network behavior explicit and disabled by default unless required.

## Output

Return tested versions, type and method evidence, patch/FFI design, files changed, build commands, compatibility tests, packaging result, known conflicts, rollback and remaining reverse-engineering uncertainty.
