Doorstop is a tool to execute managed .NET assemblies inside Unity as early as possible.
This is a total rewrite of UnityDoorstop 3. See list of breaking changes for more information.
- Runs first: Doorstop runs its code before Unity can do so
- Configurable: An elementary configuration file allows you to specify your assembly to execute
- Multiplatform: Supports Windows, Linux, macOS
- Debugger support: Allows to debug managed assemblies in Visual Studio, Rider or dnSpy without modifications to Mono
Unity runtime support
Doorstop supports executing .NET assemblies in both Unity Mono and Il2Cpp runtimes. Depending on the runtime the game uses, Doorstop tries to run your assembly as follows:
- On Unity Mono, your assembly is executed in the same runtime. As a result
- You don't need to include your custom Common Language Runtime (CLR); the one bundled with the game is used
- Your assembly is run alongside other Unity code
- You can access all Unity API directly
- On Il2Cpp, your assembly is executed in CoreCLR runtime because Il2Cpp cannot run managed assemblies. As a result:
- You need to include .NET 6 or newer CoreCLR runtime with your managed assembly
- Your assembly is run in a runtime that is isolated from Il2Cpp
- You can access Il2Cpp runtime by interacting with its native
Doorstop uses xmake to build the project. To build, run
Available build options:
-with_logging: build with logging enabled
-arch: the architectures to build for, separated by commas (e.g.
-debug: build in debug mode (currently only for *nix)
Note: Initial build times are usually slower because the build script automatically downloads and installs xmake.
On Unix, xmake is built directly from the source code.
Minimal injection example
To have Doorstop inject your code, create
Entrypoint class into
Define a public static
Start method in it:
public static void Start()
File.WriteAllText("doorstop_hello.log", "Hello from Unity!");
You can then define any code you want in
NOTE: On UnityMono, Doorstop bootstraps your assembly with a minimal number of assemblies and minimal configuration. This early execution allows for some interesting tricks, like redirecting the loading of some game assemblies. Bear also in mind that some of the Unity runtime is not initialized at such an early stage, limiting the code you can execute. You might need to appropriately pause the execution of your code until the moment you want to modify the game.
Doorstop environment variables
Doorstop sets some environment variables useful for code execution:
|Always set to
TRUE. Use to determine if your code is run via Doorstop.
|Path to the assembly executed by Doorstop relative to the current working directory.
|Path to the application executable where the injected assembly is run.
|UnityMono: Path to the game's
Managed folder. Il2Cpp: Path to CoreCLR's base class library folder.
|Paths where the runtime searchs assemblies from by default, separated by OS-specific separator (
; on windows and
: on *nix).
|Only on UnityMono: Full path to the mono runtime library.
Doorstop 4 supports debugging the assemblies in the runtime. At the moment, debugging is somewhat limited depending on the runtime.
Debugging in UnityMono
At the moment, debugging is supported in Unity 2017+ games.
To enable debugging, set
true and optionally change the debug server address via
debug_address (see configuration options).
After launching the game, you may connect to the debugger using the server address (default is
By default, the game won't wait for the debugger to connect; you may change the behaviour with the
If you use dnSpy, you can use the
Debug > Start Debugging > Debug engine > Unityoption, automatically setting the correct debugging configuration.
Doorstop detects dnSpy and automatically enables debugging without any extra configuration.
Debugging in Il2Cpp
Debugging is automatically enabled in CoreCLR.
To start debugging, compile your DLL in debug mode (with embedded or portable symbols) and start the game with the debugger of your choice.
Alternatively, attach a debugger to the game once it is running. All standard CoreCLR debuggers should detect the CoreCLR runtime in the game.
Moreover, hot reloading is supported for Visual Studio, Rider and other debuggers with .NET 6 hot reloading feature enabled.
Note that you can only debug managed code! Because the game code is unmanaged (i.e. Il2Cpp), you cannot directly debug the actual game code. Consider using native debuggers like GDB and visual debugging tools like IDA or Ghidra to debug actual game code.
Doorstop is highly configurable based on your needs and the environment you want to use. There are two ways to configure Doorstop: via config and CLI arguments.
Via configuration file
The following CLI arguments are available on both *nix, and Windows builds:
All Doorstop arguments start with
--doorstop- and always contain an argument. The arguments can be of the following type:
string= any sequence of characters and numbers. Wrap into
"s if the string contains spaces
|Enable or disable Doorstop.
|Only on Windows: If
true Unity's output log is redirected to
|Path to the assembly to load and execute.
|Overrides default Mono DLL search path
|If true, Mono debugger server will be enabled
|Whether to suspend the game execution until the debugger is attached.
|The address to use for the Mono debugger server.
|Path to coreclr library that contains the CoreCLR runtime
|Path to the directory containing the managed core libraries for CoreCLR (