Skip to content
digital_developer
Game DevUnityMethodReloadIL2CPPcom.unity.pipeline

Unity's experimental MethodReload skips domain reload, on device too

Unity has released MethodReload, an experimental package that swaps in edited method bodies without a domain reload, in the Editor and on IL2CPP development players. It covers small gameplay tweaks only and runs a subset of C#.

Digital Developer Desk, 12h ago, 3 min read

Unity has made MethodReload available as an experimental package. Tag a method with the [MethodReload] attribute, start the watcher, enter Play Mode or attach a development player, and edit the body. The running instance picks up the new body on its next call. Unity says it demoed the feature on stage at Unite Seoul.

The package is com.unity.pipeline, currently at 0.7.0-exp.1, and it requires Unity 6.0 or later. Install it through the Unity CLI or Package Manager using "Install package by technical name". Unity notes that the process may change because the feature is experimental. Tagged methods must be public, instance or static, and return void or IEnumerator. Anything else is skipped at build time with a warning.

The key limit is scope. A reload changes only tagged method bodies and never touches call sites, fields or type layout. A reloaded body can declare and call a new method, but that method cannot itself be a reload entry point. Edits run through a hand-built interpreter, so some C# is off limits inside tagged bodies, including await and Task, try/catch/finally, lock, LINQ query syntax, ref/out/in parameters and generic methods. A Roslyn analyzer ships with the package and flags violations in the IDE.

On device, interpreted code can only call APIs the player already exposes, because IL2CPP strips unreferenced code. The push lists missing members as warnings, and the code throws an exception if it reaches one. Interpreted code is also slower than compiled code, but only for tagged methods in development builds. In release builds, a tagged method just runs its compiled body. Coroutines pick up changes only when started, and in-flight ones keep their old body. An [OnMethodReloaded] callback can restart long-lived loops.

Unity compares it with existing tools. Asset Store packages patch a running Mono runtime and offer full C# in reloaded bodies, but they do not work with IL2CPP players. .NET Hot Reload in Visual Studio and Rider targets CoreCLR, not Unity's Mono or IL2CPP. Unity's own advice is that if your iteration pain is in the Editor, keep using mature tools. If it is on an IL2CPP device, MethodReload is the one to try. It suggests testing in the Editor first, since the same interpreter runs there, and says the command reference and constraint list are in the com.unity.pipeline docs.

Sources

Get the daily brief

The five stories that matter, every weekday morning. Free.