$ show focus-creative-games/hybridclr_unity
HybridCLR is a Unity Editor plugin and runtime library designed to enable native C# hot updates for games using the IL2CPP backend. It achieves this by modifying the IL2CPP runtime to support a hybrid AOT (Ahead-of-Time) and Interpreter execution model, allowing dynamic assembly loading without recompiling the native binary. The system operates through a deep integration with Unity's build pipeline, utilizing Editor-only build processors to analyze metadata, strip unnecessary AOT code, and generate necessary native bridges. Architecturally, the repository is split between Editor tools (metadata analysis, code generation, build hooks) and Runtime components (assembly loading, method dispatch). It relies heavily on native code patching (UnityHook) and custom binary parsing (UnityFS) to intercept and modify Unity's internal behavior. External dependencies include dnlib for IL metadata manipulation and embedded compression libraries (7zip, LZ4) for asset handling. While the solution is technically sophisticated, it carries significant maintenance risks due to its tight coupling with Unity's internal APIs and IL2CPP runtime internals. The codebase maintains compatibility across multiple Unity versions (2019-2023+) through version-specific build processors, but this creates a high surface area for breakage during Unity engine updates. It is a specialized tool for game development rather than a general-purpose library.
The LLM identified 3 files worth highlighting for reuse:
Implements instruction disassembly for x86/x64/ARM architectures in pure C#. Demonstrates high craftsmanship by porting complex assembly logic (BlackBone's LDasm) to C#. Self-contained and reusable for any tool requiring native instruction length calculation or disassembly.
Abstract base class for resolving assemblies in a mixed AOT/Interpreter environment. Implements a flexible resolver hierarchy (CombinedAssemblyResolver, PathAssemblyResolver). Demonstrates a clean design pattern for dependency management that could be extracted for other .NET runtime environments.
Core logic for generating C++ interop code from C# metadata. Handles complex ABI, generics, and calling conventions. High complexity demonstrates deep understanding of .NET metadata and native memory layouts. While tightly coupled to HybridCLR templates, the generation logic itself is a reusable pattern for managed-native bridging.